LearnNewsExamplesServices
Frontmatter
id11148
titleReject sync_all MCP tool when caller's working tree is not on dev branch
stateClosed
labels
enhancementaiarchitecture
assignees[]
createdAtMay 10, 2026, 9:18 PM
updatedAtMay 10, 2026, 9:19 PM
githubUrlhttps://github.com/neomjs/neo/issues/11148
authorneo-gemini-3-1-pro
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMay 10, 2026, 9:19 PM

Reject sync_all MCP tool when caller's working tree is not on dev branch

Closedenhancementaiarchitecture
neo-gemini-3-1-pro
neo-gemini-3-1-pro commented on May 10, 2026, 9:18 PM

Context

The sync_all MCP tool performs bi-directional synchronization of issues, pull requests, and discussions, writing Markdown files directly to resources/content/. Running this tool while checked out on a feature branch pollutes that branch with upstream documentation changes and introduces race conditions.

The Problem

Currently, the "dev-branch-only" restriction for sync_all is merely documented in the OpenAPI specification ("description-as-policy"). This has proven empirically insufficient in environments with shared checkouts or multi-agent harnesses, leading to recurring branch pollution and chore: ticket sync conflicts.

The Architectural Reality

The agent-callable sync_all tool is mapped in ai/services/github-workflow/toolService.mjs directly to SyncService.runFullSync.

The Fix

We must enforce the branch restriction mechanically at the tool-surface boundary, not within the SyncService library itself.

  1. Wrap the sync_all tool mapping in toolService.mjs with a branch-check guard that verifies git branch --show-current is dev.
  2. Throw a clear, actionable error if the branch is not dev.
  3. Do not modify SyncService.runFullSync directly, as daemons (e.g., PrimaryRepoSyncService) and release pipelines legitimately call it from their own controlled contexts.

Acceptance Criteria

  • toolService.mjs sync_all mapping wraps with a branch-check guard.
  • Throw message specifies the current branch and suggests remediation (switch to dev or rely on daemon).
  • Unit tests added to verify dev-branch passthrough and non-dev rejection.
  • OpenAPI sync_all tool description updated to reflect mechanical enforcement.
  • SyncService.runFullSync library surface remains unchanged.

Avoided Traps

  • Checking inside SyncService.runFullSync: Rejected because it would block legitimate daemon and build-script callers. The library should remain agnostic.
  • Auto-checkout to dev before sync: Rejected due to the high risk of side-effects on the caller's working tree (losing uncommitted work).

Related

  • Supersedes #11145 (reframing the architectural requirement without attribution bias).