Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(ingest): an ix mcp timeout stops the commit loop as the run deadline (CL-14)
KageBinaryc15c81cc2b63
diff --git a/ix-cli/src/cli/__tests__/ingest-files.test.ts b/ix-cli/src/cli/__tests__/ingest-files.test.tsindex 831d103d..dda16f27 100644--- a/ix-cli/src/cli/__tests__/ingest-files.test.ts+++ b/ix-cli/src/cli/__tests__/ingest-files.test.ts@@ -11,6 +11,7 @@ import { acquireMapLock, takeMapRerun } from "../single-flight.js";import { ingestMtimeCachePath, ingestRebuildPath, loadConfig } from "../config.js";import { workspaceIdForPath } from "../system.js";import { FakeBackend } from "./helpers/fake-backend.js";+import { runWithSignal } from "../../client/run-signal.js";import { loadIngestBaseline } from "../ingest-baseline.js";import { detectStaleFiles } from "../stale.js";import { renderStatusLlm } from "../commands/status.js";@@ -527,6 +528,30 @@ describe("ingestFiles against a fake backend", () => {expect(message).not.toContain("added load");});+ it("treats an `ix mcp` run's abort as the run deadline (CL-14)", async () => {+ // The same shape as the case above, but the deadline arrives the way a+ // timed-out MCP tool call delivers it: as the run signal, with no+ // `deadlineSignal` passed. The client saw it; the commit loop did not, so+ // the ingest kept sending per-file commits that the aborted signal failed+ // at once and blamed them on the backend.+ fixture(30);+ backend.refuseEverything = true;+ backend.abortAfterCommits = 3;++ const message = await runWithSignal(backend.deadlineSignal, async () => {+ try {+ await ingestFiles(repo, { format: "text", force: true, suppressOutput: true, printSummary: false });+ return "";+ } catch (err) {+ return String(err);+ }+ });++ expect(backend.commitCount).toBe(3);+ expect(message).toContain("ran out of time");+ expect(message).not.toContain("added load");+ });+it("counts a lost base-rev race as an error on the CUTOFF DRAIN too", async () => {// A backend can answer 200 and still have written nothing: `BaseRevMismatch`// means it read the latest rev outside the transaction and the rev moveddiff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.tsindex b7c7e070..5dda4418 100644--- a/ix-cli/src/cli/commands/ingest.ts+++ b/ix-cli/src/cli/commands/ingest.ts@@ -10,6 +10,7 @@ import { ParsePool } from './parse-pool.js';// import { ResolveWorker } from './resolve-pool.js';import chalk from 'chalk';import { IxClient } from '../../client/api.js';+import { combineSignals, currentRunSignal } from '../../client/run-signal.js';import type { GraphPatchPayload } from '../../client/types.js';import { canonicalWorkspacePath, isPathInside, resolveWorkspaceRoot, clearMapResultCache, clearStitchScopeCache } from '../config.js';import { resolveIngestRoot } from '../map-root.js';@@ -1515,6 +1516,12 @@ export async function ingestFiles(path: string,opts: { recursive?: boolean; force?: boolean; format: string; root?: string; debug?: boolean; printSummary?: boolean; suppressOutput?: boolean; lang?: string; mapMode?: boolean; exclude?: string[]; deadlineSignal?: AbortSignal }): Promise<IngestFilesSummary> {+ // Under `ix mcp` the tool call's deadline is this run's deadline too. The+ // client would see it anyway (createClient combines it), but the commit loop,+ // the stitch wait and the outcome report all read `opts.deadlineSignal`: left+ // out of it, a timed-out ingest kept fanning out per-file commits that failed+ // at once on the aborted signal and charged them to the backend.+ opts = { ...opts, deadlineSignal: combineSignals(opts.deadlineSignal, currentRunSignal()) };const debug = opts.debug || process.env.IX_DEBUG === '1';const mapMode = opts.mapMode === true;const trueStart = performance.now();