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(map): keep ix map --silent to one line; pin the --github patch id and paging
KageBinary60b1a430b91b
diff --git a/ix-cli/src/cli/__tests__/github-fetch.test.ts b/ix-cli/src/cli/__tests__/github-fetch.test.tsindex 68aa02bc..ec9124f0 100644--- a/ix-cli/src/cli/__tests__/github-fetch.test.ts+++ b/ix-cli/src/cli/__tests__/github-fetch.test.ts@@ -1,8 +1,9 @@// Copyright 2026 Ix Infrastructure Inc.-import { describe, expect, it } from "vitest";+import { afterEach, describe, expect, it, vi } from "vitest";-import { ghFetchList } from "../github/fetch.js";+import { githubPatchId } from "../commands/ingest.js";+import { fetchGitHubData, ghFetchList } from "../github/fetch.js";describe("parseGitHubRepo", () => {it("parses owner/repo format", async () => {@@ -55,3 +56,62 @@ describe("ghFetchList", () => {expect(small.urls).toEqual(["https://api.github.com/x?per_page=30&page=1"]);});});++describe("fetchGitHubData", () => {+ afterEach(() => vi.unstubAllGlobals());++ /** Stubs fetch with endpoints that each hold `total` items; returns the URLs asked for. */+ const stubGitHub = (total: number) => {+ const urls: string[] = [];+ vi.stubGlobal("fetch", async (url: string) => {+ urls.push(url);+ const q = new URL(url).searchParams;+ const perPage = Number(q.get("per_page") ?? 30);+ const start = (Number(q.get("page") ?? 1) - 1) * perPage;+ const n = Math.max(0, Math.min(perPage, total - start));+ const body = Array.from({ length: n }, (_, i) => ({ number: start + i + 1, comments: 0 }));+ return new Response(JSON.stringify(body), { status: 200 });+ });+ return urls;+ };++ it("pages every list past 100, commits to twice the limit, and keeps since on the commits query", async () => {+ const urls = stubGitHub(10_000);+ const data = await fetchGitHubData({ owner: "o", repo: "r" }, "t", { since: "2026-01-01", limit: 300 });++ expect(data.issues).toHaveLength(300);+ expect(data.pullRequests).toHaveLength(300);+ expect(data.commits).toHaveLength(600);+ const commitUrls = urls.filter(u => u.includes("/commits?"));+ expect(commitUrls).toHaveLength(6);+ expect(commitUrls[0]).toBe("https://api.github.com/repos/o/r/commits?since=2026-01-01&per_page=100&page=1");+ });++ it("builds a well-formed commits query without since", async () => {+ const urls = stubGitHub(5);+ await fetchGitHubData({ owner: "o", repo: "r" }, "t", { limit: 2 });+ expect(urls.filter(u => u.includes("/commits"))).toEqual(["https://api.github.com/repos/o/r/commits?per_page=4&page=1"]);+ });+});++describe("githubPatchId", () => {+ const repo = { owner: "o", repo: "r" };+ const ops = [{ type: "UpsertNode", id: "n1", attrs: { title: "a" } }];++ it("is the same on every run for the same ops, whatever the clock says", () => {+ const first = githubPatchId(repo, ops);+ vi.useFakeTimers();+ try {+ vi.setSystemTime(new Date("2030-01-01T00:00:00Z"));+ expect(githubPatchId(repo, structuredClone(ops))).toBe(first);+ } finally {+ vi.useRealTimers();+ }+ });++ it("changes when what is sent changes, or when the repo does", () => {+ const base = githubPatchId(repo, ops);+ expect(githubPatchId(repo, [{ ...ops[0], attrs: { title: "b" } }])).not.toBe(base);+ expect(githubPatchId({ owner: "o", repo: "other" }, ops)).not.toBe(base);+ });+});diff --git a/ix-cli/src/cli/__tests__/map-baseline.test.ts b/ix-cli/src/cli/__tests__/map-baseline.test.tsindex 3d20789d..4965de50 100644--- a/ix-cli/src/cli/__tests__/map-baseline.test.ts+++ b/ix-cli/src/cli/__tests__/map-baseline.test.ts@@ -6,7 +6,7 @@ import * as os from "node:os";import * as path from "node:path";import { persistIngestBaselineIfClean } from "../commands/ingest.js";-import { describeTooLargeFiles, persistCompletedMapBaseline } from "../commands/map.js";+import { describeTooLargeFiles, persistCompletedMapBaseline, silentSummaryLine } from "../commands/map.js";import { loadMapBaseline, saveMapBaseline } from "../map-baseline.js";import { ingestMtimeCachePath } from "../config.js";import { hasCompletedMapBaseline } from "../stale.js";@@ -191,3 +191,15 @@ describe("describeTooLargeFiles", () => {expect(describeTooLargeFiles(undefined)).toBeUndefined();});});++describe("silentSummaryLine", () => {+ const base = { files: 12, systems: 1, subsystems: 2, modules: 3, mapMs: 40, stitch: "" };++ it("keeps --silent to one line, carrying the oversized-file count as a token", () => {+ expect(silentSummaryLine(base)).toBe("map: 12 files · 1s/2ss/3m regions · 40ms\n");+ expect(silentSummaryLine({ ...base, filesTooLarge: 0 })).toBe("map: 12 files · 1s/2ss/3m regions · 40ms\n");+ const line = silentSummaryLine({ ...base, stitch: " · stitch_skipped_rule=cooling", filesTooLarge: 2 });+ expect(line).toBe("map: 12 files · 1s/2ss/3m regions · 40ms · stitch_skipped_rule=cooling · too_large=2\n");+ expect(line.split("\n")).toHaveLength(2);+ });+});diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.tsindex 394dc44d..74a26476 100644--- a/ix-cli/src/cli/commands/ingest.ts+++ b/ix-cli/src/cli/commands/ingest.ts@@ -4276,6 +4276,16 @@ export function githubCommitFailure(result: { status?: string }): string | undef"(BaseRevMismatch), so nothing was ingested. Run the command again once other ingests have finished.";}+/**+ * The `--github` patch id, from what is sent rather than the clock: the same+ * issues, PRs and commits give the same id, so re-running an unchanged ingest+ * is a no-op on the backend instead of a new revision of identical facts.+ * Exported for tests.+ */+export function githubPatchId(repo: { owner: string; repo: string }, ops: unknown[]): string {+ return deterministicId(`github://${repo.owner}/${repo.repo}:${sha256(Buffer.from(JSON.stringify(ops)))}`);+}+async function ingestGitHub(opts: {github?: string; token?: string; since?: string;limit: string; format: string;@@ -4306,10 +4316,7 @@ async function ingestGitHub(opts: {for (const commit of data.commits) allOps.push(...transformCommit(repo, commit));const patch: GraphPatchPayload = {- // From what is sent, not the clock: the same issues, PRs and commits give- // the same id, so re-running an unchanged ingest is a no-op on the backend- // instead of a new revision of identical facts.- patchId: deterministicId(`github://${repo.owner}/${repo.repo}:${sha256(Buffer.from(JSON.stringify(allOps)))}`),+ patchId: githubPatchId(repo, allOps),// IX_PATCH_ACTOR="" lets a kOS cloud backend stamp the verified principal// (it 403s a non-empty actor that differs from it); see core-ingestion patchActor().actor: process.env.IX_PATCH_ACTOR ?? 'ix/github-ingest',diff --git a/ix-cli/src/cli/commands/map.ts b/ix-cli/src/cli/commands/map.tsindex 37fd14b2..ad8eb29e 100644--- a/ix-cli/src/cli/commands/map.ts+++ b/ix-cli/src/cli/commands/map.ts@@ -287,13 +287,32 @@ export function describeDroppedFiles(function emitDroppedFileWarning(ingest: Pick<IngestFilesSummary, "parseErrors" | "commitErrors" | "filesTooLarge"> | undefined,+ silent: boolean,): void {const message = describeDroppedFiles(ingest);if (message) process.stderr.write(chalk.yellow(` ${message}\n`));+ // Not under --silent: an oversized file is counted on every run, not only+ // the one that first met it, so a line here would turn the hook surface's+ // one summary line into two on every map of such a repo. `silentSummaryLine`+ // carries the count as a token instead.+ if (silent) return;const tooLarge = describeTooLargeFiles(ingest);if (tooLarge) process.stderr.write(chalk.dim(` ${tooLarge}\n`));}+/**+ * The one stderr line `ix map --silent` prints. `too_large=N` appears only+ * when files were left out for size, so a repo without any keeps the line it+ * always had. Exported for tests.+ */+export function silentSummaryLine(s: {+ files: number; systems: number; subsystems: number; modules: number; mapMs: number;+ stitch: string; filesTooLarge?: number;+}): string {+ const tooLarge = (s.filesTooLarge ?? 0) > 0 ? ` · too_large=${s.filesTooLarge}` : "";+ return `map: ${s.files} files · ${s.systems}s/${s.subsystems}ss/${s.modules}m regions · ${s.mapMs}ms${s.stitch}${tooLarge}\n`;+}+/*** Files over the 1 MB parse limit are left out of the map. `ix ingest` lists* them in its summary; `ix map` said nothing, so a large generated or vendored@@ -1053,7 +1072,7 @@ async function runMapCommand(pathArg: string | undefined, opts: { format: string// plugins read this command's JSON through runners that discard stdout on// a non-zero exit, so failing here would hide the very diagnostics the// caller needs (the #539 lesson).- emitDroppedFileWarning(localIngest);+ emitDroppedFileWarning(localIngest, silent);if (silent) {const systems = result.regions.filter(r => r.label_kind === "system").length;@@ -1084,9 +1103,10 @@ async function runMapCommand(pathArg: string | undefined, opts: { format: string// `stitch_skipped=cooling` on this line silently stopped matching// the moment it was pointed at `--format json`.: ` · stitch_skipped_rule=${rule}`;- process.stderr.write(- `map: ${result.file_count} files · ${systems}s/${subsystems}ss/${modules}m regions · ${mapMs}ms${stitch}\n`- );+ process.stderr.write(silentSummaryLine({+ files: result.file_count, systems, subsystems, modules, mapMs, stitch,+ filesTooLarge: localIngest?.filesTooLarge,+ }));return;}