feat: make master-parity live-remote aware so a stale daemon fails closed (Closes #610) #788
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#788
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 #610
Head
324b4b3e9312840b44d1587d8b9142a76ca5ef74Publication recovery only: existing commits on
feat/issue-610-live-remote-paritywere already present onprgsand matched local HEAD. No amend, squash, rebase, or force was performed. This PR opens the missing review surface.Problem
gitea_assess_master_paritycompared only the daemon startup commit against the local on-disk HEAD. When the checkout was not updated, parity reported green even though live remote master had advanced, so a stale daemon could claim a mutation-safe result while running outdated capability gates (observed during PR #592 recovery, where the resolver correctly required restart but parity saidin_parity=true).Implementation summary
master_parity_gate.assess_master_parity()accepts optionallive_remote_headand reports three commits distinctly (daemon_start_head,local_head,live_remote_head) pluslive_known/live_stale/mutation_safe.parity_block_reasons()blocks mutations on live-staleness; read-only diagnostics stay unblocked when remote is unknown.parity_resolver_disagreement()provides a typed fail-closed blocker naming the capability resolver as authoritative when it requires restart while parity looks locally green.read_remote_master_head()best-effort live remote tip with 60s TTL; tests can pin viaGITEA_TEST_LIVE_REMOTE_HEAD.gitea_assess_master_parity/ runtime context.Files
master_parity_gate.pygitea_mcp_server.pytests/test_master_parity_gate.pyTest evidence (from authoring commit message; not re-run in this publisher)
test_configAuthIntegration /test_credentialsGetCredentials were baseline-proven keychain/env failures identical on the unmodified base (not branch-caused).Known integration note for reviewer
Branch head is from 2026-07-09 and is behind current master. Merge may need author
update_branch_by_mergeafter review; this publisher does not rewrite history or resolve conflicts.Publisher execution identity
grok-pr-publisher-prod-v1grok-pr-publisher-prod-v1-20260721T232804Z-pid18507-7b750edafeat/issue-610-live-remote-parity@324b4b3e9312840b44d1587d8b9142a76ca5ef74CTH: Author Handoff
Status: published_awaiting_independent_review
Next owner: reviewer (prgs-reviewer / sysadmin)
Current blocker: none for publication; branch is behind master and may need author update_branch_by_merge after review if conflicts appear
Decision: PR #788 created for completed committed work on issue #610; no code rewritten
Proof: gitea_create_pr → #788; head_sha
324b4b3e93matches local and prgs remote branch; base master; Closes #610; exactly one open PRNext action: independent formal review at exact head
324b4b3e93Ready-to-paste prompt: see NEXT_PROMPT below
Canonical Issue State
STATE: pr_open_awaiting_review
WHO_IS_NEXT: reviewer
NEXT_ACTION: formal independent review of PR #788 at head
324b4b3e93NEXT_PROMPT:
WHAT_HAPPENED: Publication recovery run adopted existing remote branch feat/issue-610-live-remote-parity @
324b4b3e93(already published; no push), locked issue #610 via own-branch adoption, and created PR #788 targeting master with Closes #610. Applied status:pr-open. No implementation, amend, rebase, or force-push.WHY: Completed committed work for open issue #610 was ahead of prgs/master with no PR; publisher recovers missing review surface only.
RELATED_PRS: #788 (this PR); #592 (historical incident context only, already merged)
BLOCKERS: none for review handoff; branch is 192 commits behind master so merge may later need author update_branch_by_merge
VALIDATION: Authoring-commit evidence: 13 new tests; full suite 2423 passed; 8 baseline keychain/env failures identical on unmodified base (not branch-caused). Publisher did not re-run the suite.
LAST_UPDATED_BY: jcwalker3 (prgs-author)
LLM_LOCK_ID: grok-pr-publisher-prod-v1
LLM_EXECUTION_ID: grok-pr-publisher-prod-v1-20260721T232804Z-pid18507-7b750eda
REPOSITORY: Scaled-Tech-Consulting/Gitea-Tools
ISSUE: #610
PR: #788
HEAD_SHA:
324b4b3e93BASE_BRANCH: master
BASE_OR_MERGE_SHA:
35e94e107cACTING_ROLE: author
ACTING_IDENTITY: jcwalker3
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #788
issue: #610
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 21098-3d496ddf679b
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-788
phase: claimed
candidate_head:
324b4b3e93target_branch: master
target_branch_sha:
35e94e107clast_activity: 2026-07-22T00:30:18Z
expires_at: 2026-07-22T00:40:18Z
blocker: none
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #788
issue: #610
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 21098-f5dd578979ec
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-788
phase: claimed
candidate_head:
324b4b3e93target_branch: master
target_branch_sha:
35e94e107clast_activity: 2026-07-22T00:42:18Z
expires_at: 2026-07-22T00:52:18Z
blocker: none
Verdict: REQUEST_CHANGES — PR #788 @
324b4b3e9312840b44d1587d8b9142a76ca5ef74Reviewed independently by
sysadmin/prgs-reviewer(authorjcwalker3; no self-review). Lease21098-f5dd578979ec, worktreebranches/review-pr-788, targetmaster@35e94e1.The #610 design (distinguish daemon-start / local / live-remote heads; fail closed on live-stale; resolver authoritative) is sound and well-scoped, and the 37 new
test_master_parity_gate.pycases pass. One blocking defect:F1 (blocking) — live-remote parity read is not hermetic; 107 pre-existing tests broken
read_remote_master_head()performs a realgit ls-remotewheneverGITEA_TEST_LIVE_REMOTE_HEADis unset, and nothing pins that variable suite-wide (notests/conftest.pyentry; grep shows the only references are the new module/tests). Whenever the checkout HEAD differs from live remote master — i.e. every canonicalbranches/feature worktree, the exact environment this workflow requires all test runs to use —gitea_get_runtime_context/gitea_assess_master_parityreportlive_staleand flipsafe_next_action, breaking legacy suites that assert runtime-context content.Proof (venv python,
pytest -q):324b4b3full suite: 115 failed, 2316 passed.5201379(detached baseline worktree) full suite, identical command: 8 failed, 2404 passed — the 8 are the declared keychain/env baseline set (test_configAuthIntegration /test_credentialsGetCredentials).test_mcp_server.py test_runtime_clarity.py test_resolve_task_capability.py): branch 54 failed / 190 passed vs baseline 244 passed / 0 failed.test_get_runtime_context_reviewer: got"Daemon is stale relative to LIVE remote master (started 324b4b3e9312, live master 35e94e107c32); …"where the test asserts"None; ready for operations.".GITEA_TEST_LIVE_REMOTE_HEADoutside the tests does not rescue them: the failing tests usepatch.dict(os.environ, …, clear=True), which wipes the pin, so the code falls through to a real networkls-remoteinside unit tests.Required remediation: make the live-remote read hermetic for the test suite — e.g. a
conftest.pypin ofGITEA_TEST_LIVE_REMOTE_HEAD, or disabling the live probe under pytest unless explicitly opted in — and update the affected legacy expectations for the new runtime-context fields/safe_next_actionso the full suite is green (minus the 8 baseline failures) when run from abranches/worktree whose HEAD differs from live master.F2 (non-blocking) — unit tests gain a network dependency
With F1 unfixed, every cold-cache test run performs
git ls-remote(5s timeout) against the real remote; offline runs silently change behavior (live_known=False→mutation_safe=Falseyet unblocked). The hermetic fix for F1 should remove this too.Note (non-blocking) — semantics of unknown live state
mutation_safe=Falsewhen the live head is unknown, butparity_block_reasons()does not block on unknown — documented and defensible (resolver stays authoritative); calling it out so the choice is deliberate.Integration note
The branch is ~12 days behind master (
mergeable: truetoday). After F1/F2 remediation, expect an authorupdate_branch_by_mergesync before merge; the reviewer handoff in the PR body already anticipates this.Validation ledger
master_parity_gate.py(+188/−26 net),gitea_mcp_server.py(+73),tests/test_master_parity_gate.py(+198). Scoped, no secrets, no gate weakening found.tests/test_master_parity_gate.py: 37 passed.gitea_load_review_workflowhash263d0a6cb8a6, boundary clean; head pinned324b4b3; verdict recorded viagitea_mark_final_review_decision.Canonical PR State
STATE: changes-requested
WHO_IS_NEXT: author
NEXT_ACTION: Remediate F1 (hermetic live-remote read / conftest pin + updated legacy expectations) and F2 on the PR branch, re-run the full suite from a branches/ worktree, then request re-review.
NEXT_PROMPT:
WHAT_HAPPENED: Independent review of PR #788 @
324b4b3found the #610 live-remote parity design sound but non-hermetic: 107 pre-existing tests break whenever the checkout HEAD differs from live remote master (115 failed vs 8 baseline-identical failures at merge-base5201379).WHY: The live-remote
git ls-remoteprobe is unpinned in the test suite; canonical branches/ worktree test runs always differ from live master, so runtime-context/parity outputs flip to live_stale and break legacy assertions.ISSUE: #610
HEAD_SHA:
324b4b3e93REVIEW_STATUS: changes-requested
MERGE_READY: no
BLOCKERS: F1 (blocking) non-hermetic live-remote parity read breaking 107 tests; F2 (non-blocking) unit-test network dependency; branch ~12 days behind master (author update_branch_by_merge after fixes).
VALIDATION: Focused test_master_parity_gate.py 37 passed; focused 3-suite compare branch 54 failed/190 passed vs baseline 244 passed; full suite branch 115 failed/2316 passed vs pristine merge-base 8 failed/2404 passed (8 = declared keychain/env baseline set); diff inspected, scoped, no secrets.
LAST_UPDATED_BY: sysadmin / prgs-reviewer (independent reviewer; lease 21098-f5dd578979ec)
CTH: Author Handoff
Status: published_awaiting_independent_review
Next owner: reviewer (prgs-reviewer / sysadmin)
Current blocker: none for re-review; prior REQUEST_CHANGES (review 496 @
324b4b3) remediatedDecision: F1/F2 hermetic live-remote fix published; ready for independent re-review
Proof: gitea_commit_files →
57a52b1a9933a7093498d988911f90a325615714onfeat/issue-610-live-remote-parity; PR #788 head matches; branch already mergeable vs current master (prior update-by-merge at344dc41)Next action: independent formal re-review at exact head
57a52b1a9933a7093498d988911f90a325615714Ready-to-paste prompt: see NEXT_PROMPT below
Remediation of review 496 (F1/F2)
F1 (blocking) — hermetic live-remote reads
master_parity_gate.set_hermetic_test_mode(True)enabled suite-wide via autouse fixture intests/conftest.py.GITEA_TEST_LIVE_REMOTE_HEADis unset,read_remote_master_headreturnsNonewithoutgit ls-remote(module flag survivespatch.dict(..., clear=True)).PYTEST_CURRENT_TESTis set unlessGITEA_TEST_ALLOW_LIVE_REMOTE_PROBE.F2 (non-blocking) — no unit-test network dependency
ls-remotefrom the suite.Files:
master_parity_gate.py,tests/conftest.py,tests/test_master_parity_gate.py(+3 hermetic cases).Validation (from allocated worktree)
Run with
/Users/jasonwalker/Development/Gitea-Tools/venv/bin/python -m pytestat worktreebranches/author-issue-610-publish-lock@57a52b1:tests/test_master_parity_gate.py— 40 passedtest_mcp_server.py+test_runtime_clarity.py+test_resolve_task_capability.py) — 244 passed, 1 failedBaseline comparison: master
620ed6e9a955(worktreebranches/baseline-master-issue-790) fails the same single focused caseTestPreflightVerification::test_declared_clean_task_worktree_ignores_control_checkout_violation. The eleven full-suite failures match the baseline set documented on PR #794 (commit_payloads ×6, issue_702 F1/F2 ×2, that preflight case, post_merge_moot_lease, reconciler_supersession_close). Prior review head324b4b3had 115 failed; after F1 hermetic + master merge: 11 failed (baseline only). No new branch-caused failures.Canonical Issue State
STATE: pr_open_awaiting_review
WHO_IS_NEXT: reviewer
NEXT_ACTION: formal independent re-review of PR #788 at head
57a52b1a99NEXT_PROMPT:
WHAT_HAPPENED: Author remediates review 496 F1/F2 on issue #610 / PR #788. Published commit
57a52b1via gitea_commit_files from worktree branches/author-issue-610-publish-lock after renewing the expired exact-owner author lock. Prior head344dc41already included master merge; this commit adds hermetic test isolation only.WHY: REQUEST_CHANGES required hermetic live-remote parity reads so feature worktrees do not break 100+ legacy runtime-context tests.
RELATED_PRS: #788 (this PR)
BLOCKERS: none for re-review
VALIDATION: test_master_parity_gate 40 passed; focused 244 passed / 1 baseline fail; full 4262 passed / 11 baseline fail / 6 skipped; head read-back
57a52b1matches gitea_get_pr_review_feedback current_head_shaLAST_UPDATED_BY: jcwalker3 (prgs-author)
LLM_LOCK_ID: grok-pr-queue-author-788
LLM_EXECUTION_ID: grok-pr-queue-author-788-20260722T1036Z
REPOSITORY: Scaled-Tech-Consulting/Gitea-Tools
ISSUE: #610
PR: #788
HEAD_SHA:
57a52b1a99BASE_BRANCH: master
BASE_OR_MERGE_SHA:
620ed6e9a9ACTING_ROLE: author
ACTING_IDENTITY: jcwalker3
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #788
issue: #610
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 89687-2a94cee47d5c
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr-788
phase: claimed
candidate_head:
57a52b1a99target_branch: master
target_branch_sha:
620ed6e9a9last_activity: 2026-07-22T10:43:50Z
expires_at: 2026-07-22T10:53:50Z
blocker: none
Verdict: APPROVE — PR #788 @
57a52b1a9933a7093498d988911f90a325615714Reviewed independently by
sysadmin/prgs-reviewer(authorjcwalker3; no self-review). Lease session89687-2a94cee47d5c/ comment 14084, worktreebranches/review-pr-788, targetmaster@620ed6e9a955.Re-evaluation of review 496
F1 (was blocking) — RESOLVED
Hermetic live-remote isolation is now suite-wide:
_HERMETIC_TEST_MODEdefault False (production probes).tests/conftest.pyautouse_hermetic_live_remote_master_headenables hermetic for pytest and disables infinally.PYTEST_CURRENT_TESTset) and no override /GITEA_TEST_ALLOW_LIVE_REMOTE_PROBE,read_remote_master_headreturnsNonewithoutgit ls-remote.patch.dict(..., clear=True)— independent proof: subprocess never called under cleared env.GITEA_TEST_ALLOW_LIVE_REMOTE_PROBEwhile still mocking subprocess.Independent production-path proof (no hermetic, no pytest env):
read_remote_master_headstill issuesgit ls-remoteonce. Server_current_master_parity()still wires live head intoassess_master_parity.F2 (was non-blocking) — RESOLVED
Unit tests no longer cold-cache network
ls-remoteunder suite hermetic mode.Non-blocking residual note (not a merge blocker)
Defense-in-depth uses
PYTEST_CURRENT_TEST. A production process whose environment was polluted with that variable would skip the live probe. That is not the normal production path (_HERMETIC_TEST_MODEdefaults false; MCP daemon is not under pytest). Documented for operators only.Unknown live-state semantics
Unchanged and still defensible:
mutation_safe=Falsewhen live unknown;parity_block_reasons()does not block on unknown alone; resolver remains authoritative.Scope / independence
master_parity_gate.py,gitea_mcp_server.py,tests/conftest.py,tests/test_master_parity_gate.pyonly — scoped to #610.57a52b1; matches live PR head.master; mergeable; author != reviewer.Independent validation ledger
Worktree
branches/review-pr-788@57a52b1:tests/test_master_parity_gate.pytest_mcp_server+test_runtime_clarity+test_resolve_task_capabilityBaseline classification: the single focused failure (
TestPreflightVerification::test_declared_clean_task_worktree_ignores_control_checkout_violation) and all 11 full-suite failures reproduce on master620ed6e9a955(detached baseline worktree). Baseline, not branch-caused. Prior review head had 115 failures; current head restores parity with master failure set.Manual hermetic/production path probes: PRODUCTION_PROBE_OK, HERMETIC_OK, CLEAR_TRUE_OK, PYTEST_ENV_OK, OVERRIDE_OK.
Canonical PR State
STATE: approved
WHO_IS_NEXT: merger
NEXT_ACTION: merge PR #788 at exact head
57a52b1a99through sanctioned merger lease and merge path; do not self-merge from this reviewer sessionNEXT_PROMPT:
WHAT_HAPPENED: Independent re-review of remediating head
57a52b1found F1/F2 fully resolved; production live-remote probe intact; suite hermetic isolation correct; remaining failures are master baseline.WHY: Author remediated non-hermetic ls-remote that broke feature-worktree test runs.
ISSUE: #610
HEAD_SHA:
57a52b1a99REVIEW_STATUS: approved
MERGE_READY: true
BLOCKERS: none
VALIDATION: Independent focused and full suite as above; production vs hermetic path proofs; review 496 findings closed
NATIVE_REVIEW_PROOF: transport=native_mcp; entrypoint=mcp_server; token_fingerprint=73c82cf6a9dcf507
LAST_UPDATED_BY: sysadmin / prgs-reviewer
adopted_at: 2026-07-22T10:51:07Z
adopted_by_identity: sysadmin
adopted_by_profile: prgs-merger
adopted_from_session_id: 89687-2a94cee47d5c
adopted_from_profile: prgs-reviewer
adopted_from_reviewer_identity: sysadmin
adopted_from_comment_id: 14084
adoption_reason: merger-handoff-approved-head
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #788
issue: #610
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 18017-014f996adf50
worktree: /Users/jasonwalker/Development/Gitea-Tools
phase: adopted
candidate_head:
57a52b1a99target_branch: master
target_branch_sha:
620ed6e9a9last_activity: 2026-07-22T10:51:07Z
expires_at: 2026-07-22T11:01:07Z
blocker: none
Stale #332 review-decision lock cleanup (#594)
Status: APPLIED
sysadminprgs-merger2026-07-22T10:51:57.674278+00:00approveon PR feat: make master-parity live-remote aware so a stale daemon fails closed (Closes #610) (#788)closed(merged=True)5032965e3a39654f1d65b2a58f25931bc72ff17b1prgs-reviewerManual deletion of session-state files is not the workflow.
This path only clears a lock when the referenced PR is merged/closed.
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #788
issue: #610
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 18017-014f996adf50
worktree: /Users/jasonwalker/Development/Gitea-Tools
phase: released
candidate_head:
57a52b1a99target_branch: master
target_branch_sha:
620ed6e9a9last_activity: 2026-07-22T10:52:11Z
expires_at: 2026-07-22T11:02:11Z
blocker: manual-release