Skip to content

feat(mcp): return from index_codebase without waiting for the first index - #44

Merged
kyle-elliott merged 1 commit into
fix/tool-call-deadlinesfrom
feat/nonblocking-index-codebase
Oct 10, 2026
Merged

kyle-elliott merged 1 commit into
fix/tool-call-deadlinesfrom
feat/nonblocking-index-codebase

Conversation

@kyle-elliott

@kyle-elliott kyle-elliott commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Part 3 of 3 for #37, plus follow-up #46. Stack: #42 → #43 → this PR → #46.

Closes #37

Problem

index_codebase blocked until the whole first index finished embedding. In the reviewed sessions, 4 of 5 calls failed with host timeouts at 30–60 s.

Change

  • index_codebase returns right after the codebase is registered. It names the codebase, the path, and sync_status. A first index that is already running reports "already in progress" instead of waiting. A failed first index is still retried.
  • FirstIndexPhase (src/mcp/readiness.rs): Registering, Syncing, Embedding { job_id }, Ready, Failed { reason }. It is derived purely from the gate state and the coordinator's last job.
  • CoordinatorStatus.first_index (#[serde(default)], so a status body from an older daemon still decodes). sync_status and semctl daemon status show a first index: line.
  • Docs, skill, and evals: index_codebase no longer blocks; agents poll sync_status every 10–15 s and use local tools meanwhile. New "When a tool fails" rule: follow the next: line, retry once only when it says the call is retryable, otherwise use local Read/Grep.

Verification

  • Full gate passes, including the OMP adapter Bun test.
  • Tests: index_codebase returns while the gate is pending; concurrent, completed, and failed gates; the state-to-phase table; old-daemon status decoding; the sync_status phase line; the integration test now expects index_codebase to answer before the job completes.

Known issue (not from this stack)

In a git worktree, the pre-commit hook fails codebase::tests::git_root_preserves_native_bytes_and_trailing_whitespace and nested_git_directory_resolves_to_the_worktree_root, because git init in those tests inherits the hook's git environment. The tests pass outside the hook. All three commits used --no-verify for that reason only.

…ndex

index_codebase now returns as soon as the codebase is registered and the
first index is handed to the checkout's coordinator. A concurrent call
reports the first index as already in progress, and a completed gate is
reported as complete. A failed gate is still retried. No index_codebase
path waits on the first-index gate any more.

sync_status reports the first-index phase (registering, syncing,
embedding with its job, ready, or failed with a reason). The phase is
derived from the gate state and the coordinator's last job, is part of
CoordinatorStatus (older daemons decode as none), and shows in
semctl daemon status.

The server manual, tool docs, README, retrieval skill, and skill evals
describe the non-blocking tool, the sync_status polling loop, and the rule
to follow the next: line of a failed tool call.

Closes #37
@kyle-elliott
kyle-elliott force-pushed the feat/nonblocking-index-codebase branch from dddbfea to a93c9be Compare October 10, 2026 00:05
@kyle-elliott
kyle-elliott merged commit 08e21ab into main Oct 10, 2026
6 of 9 checks passed
@kyle-elliott
kyle-elliott deleted the feat/nonblocking-index-codebase branch October 10, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP tool failures outlast host timeouts and come back as normal results

1 participant