Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat: add ix map --full override and module load timing

Tanner Kocher4c280a387e97
diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.ts
index 9802e011..add5559a 100644
--- a/ix-cli/src/cli/commands/ingest.ts
+++ b/ix-cli/src/cli/commands/ingest.ts
@@ -95,12 +95,16 @@ export async function ingestFiles(
path: string,
opts: { recursive?: boolean; force?: boolean; format: string; root?: string; debug?: boolean }
): Promise<void> {
+ const debug = opts.debug || process.env.IX_DEBUG === '1';
+ const trueStart = performance.now();
+
const [{ parseFile, resolveEdges, isGrammarSupported }, { buildPatchWithResolution }] = await loadIngestionModules();
+ const moduleLoadMs = Math.round(performance.now() - trueStart);
+
const resolvedPath = nodePath.isAbsolute(path)
? path
: nodePath.resolve(resolveWorkspaceRoot(opts.root), path);
- const debug = opts.debug || process.env.IX_DEBUG === '1';
const client = new IxClient(getEndpoint());
const start = performance.now();
@@ -121,7 +125,7 @@ export async function ingestFiles(
let entitiesParsed = 0;
// Phase timing marks
- const timings = { discoverMs: 0, hashMs: 0, parseMs: 0, resolveMs: 0, commitMs: 0 };
+ const timings = { moduleLoadMs, discoverMs: 0, hashMs: 0, parseMs: 0, resolveMs: 0, commitMs: 0 };
const resolveStats = {
importLookups: 0, transitiveLookups: 0, globalFallbacks: 0,
globalCandidateTotal: 0, resolvedImport: 0, resolvedTransitive: 0,
@@ -271,6 +275,7 @@ export async function ingestFiles(
if (debug) {
console.log(chalk.dim(`\n Phase timings:`));
+ console.log(chalk.dim(` modules: ${timings.moduleLoadMs}ms`));
console.log(chalk.dim(` discover: ${timings.discoverMs}ms`));
console.log(chalk.dim(` hash: ${timings.hashMs}ms`));
console.log(chalk.dim(` parse: ${timings.parseMs}ms`));
diff --git a/ix-cli/src/cli/commands/map.ts b/ix-cli/src/cli/commands/map.ts
index eb96ed27..4deba5a7 100644
--- a/ix-cli/src/cli/commands/map.ts
+++ b/ix-cli/src/cli/commands/map.ts
@@ -73,6 +73,7 @@ export function registerMapCommand(program: Command): void {
.option("--format <fmt>", "Output format (text|json)", "text")
.option("--level <n>", "Show only regions at this level (1=finest, higher=coarser)")
.option("--min-confidence <n>", "Only show regions above this confidence threshold (0-1)", "0")
+ .option("--full", "Force full local map, bypassing automatic safety limits (advanced/testing)")
.addHelpText(
"after",
`
@@ -85,13 +86,20 @@ Levels:
2 = subsystem (mid-level, ~20-100 files)
3 = system (top-level architectural regions)
+Advanced:
+ --full Override automatic local safety limits and force the full local map
+ path. Bypasses automatic downgrade to fast mode and the persistence
+ safety guardrail. Intended for testing and performance diagnosis.
+
Examples:
ix map .
ix map --format json
ix map --level 2
- ix map --min-confidence 0.5`
+ ix map --min-confidence 0.5
+ ix map . --full
+ ix --debug map . --full`
)
- .action(async (pathArg: string | undefined, opts: { format: string; level?: string; minConfidence: string }) => {
+ .action(async (pathArg: string | undefined, opts: { format: string; level?: string; minConfidence: string; full?: boolean }) => {
const cwd = pathArg ? resolve(pathArg) : process.cwd();
try {
@@ -102,6 +110,14 @@ Examples:
return;
}
+ // Print warning when --full override is active
+ if (opts.full && opts.format !== "json") {
+ console.log(chalk.yellow("\nWarning"));
+ console.log(chalk.yellow(" Full local map override enabled.\n"));
+ console.log(" Ix will ignore automatic local safety limits and attempt full local mapping.");
+ console.log(" This may take a long time or fail on very large systems.\n");
+ }
+
// Ingest the path before mapping so the graph is up to date
if (opts.format !== "json") {
process.stderr.write(chalk.dim("Ingesting...\n"));
@@ -116,7 +132,7 @@ Examples:
let result: MapResult;
try {
- result = await client.map() as MapResult;
+ result = await client.map({ full: opts.full }) as MapResult;
} catch (err: any) {
const msg: string = err.message ?? "";
const structured = parseBackendError(msg);
diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.ts
index 5c9e36ed..49a09c88 100644
--- a/ix-cli/src/client/api.ts
+++ b/ix-cli/src/client/api.ts
@@ -183,8 +183,8 @@ export class IxClient {
return this.post<PatchCommitResult>('/v1/patches/bulk', { patches });
}
- async map(): Promise<any> {
- return this.post("/v1/map", {});
+ async map(opts?: { full?: boolean }): Promise<any> {
+ return this.post("/v1/map", { full: opts?.full });
}
async reset(): Promise<{ ok: boolean; message: string }> {
diff --git a/memory-layer/src/main/scala/ix/memory/api/MapRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/MapRoutes.scala
index 3f4ab1db..96c06599 100644
--- a/memory-layer/src/main/scala/ix/memory/api/MapRoutes.scala
+++ b/memory-layer/src/main/scala/ix/memory/api/MapRoutes.scala
@@ -1,7 +1,8 @@
package ix.memory.api
import cats.effect.IO
-import io.circe.Json
+import io.circe.{Decoder, Json}
+import io.circe.generic.semiauto.deriveDecoder
import io.circe.syntax._
import org.http4s.HttpRoutes
import org.http4s.circe.CirceEntityCodec._
@@ -12,12 +13,16 @@ import ix.memory.model.NodeId
class MapRoutes(mapService: MapService) {
+ private case class MapRequest(full: Option[Boolean])
+ private implicit val mapReqDecoder: Decoder[MapRequest] = deriveDecoder
+
val routes: HttpRoutes[IO] = HttpRoutes.of[IO] {
/** POST /v1/map — Run the full map pipeline and return the hierarchy. */
- case POST -> Root / "v1" / "map" =>
+ case req @ POST -> Root / "v1" / "map" =>
(for {
- archMap <- mapService.buildMap()
+ body <- req.as[MapRequest].handleErrorWith(_ => IO.pure(MapRequest(None)))
+ archMap <- mapService.buildMap(forceFullLocal = body.full.getOrElse(false))
resp <- Ok(encodeMap(archMap))
} yield resp).handleErrorWith(ErrorHandler.handle(_))
}
diff --git a/memory-layer/src/main/scala/ix/memory/map/MapService.scala b/memory-layer/src/main/scala/ix/memory/map/MapService.scala
index 200cc49c..d2b6426e 100644
--- a/memory-layer/src/main/scala/ix/memory/map/MapService.scala
+++ b/memory-layer/src/main/scala/ix/memory/map/MapService.scala
@@ -54,13 +54,14 @@ class MapService(
else if (level == 1) "module"
else "subsystem"
- def buildMap(): IO[ArchitectureMap] =
+ def buildMap(forceFullLocal: Boolean = false): IO[ArchitectureMap] =
for {
rev <- queryApi.getLatestRev
files <- builder.discoverFiles()
pf <- preflight.evaluate(files)
- result <- pf.mode match {
- case MapExecutionMode.FullLocal => buildFullLocal(files, pf, rev)
+ mode = if (forceFullLocal) MapExecutionMode.FullLocal else pf.mode
+ result <- mode match {
+ case MapExecutionMode.FullLocal => buildFullLocal(files, pf, rev, forceFullLocal)
case MapExecutionMode.FastLocal => buildFastLocal(files, pf, rev)
}
} yield result
@@ -68,7 +69,8 @@ class MapService(
private def buildFullLocal(
files: Vector[FileVertex],
pf: MapPreflightResult,
- rev: Rev
+ rev: Rev,
+ bypassPersistenceGuard: Boolean = false
): IO[ArchitectureMap] =
for {
rawGraph <- builder.buildGraph(files)
@@ -76,7 +78,7 @@ class MapService(
graph = applyPenalty(rawGraph, crosscutScores)
levels = LouvainClustering.cluster(graph, maxLevels = 3, minCommunitySize = 3)
regions = buildRegions(graph, levels, crosscutScores, rev)
- pe <- guardAndPersist(regions, rev)
+ pe <- guardAndPersist(regions, rev, bypassPersistenceGuard)
_ <- logOutcome(MapOutcome.FullLocalCompleted, pf, pe)
} yield ArchitectureMap(
regions, rawGraph.vertices.size, rev.value,
@@ -407,7 +409,11 @@ class MapService(
// ── Persistence guardrail + logging ─────────────────────────────────
- private def guardAndPersist(regions: Vector[Region], rev: Rev): IO[PersistenceEstimate] = {
+ private def guardAndPersist(
+ regions: Vector[Region],
+ rev: Rev,
+ bypassGuard: Boolean = false
+ ): IO[PersistenceEstimate] = {
if (regions.isEmpty) return IO.pure(PersistenceEstimate(0, 0, 0, 0, 0))
for {
@@ -416,14 +422,20 @@ class MapService(
_ <- logger.debug(
s"Persistence estimate: ${pe.totalOps} ops " +
s"(${pe.regionNodes} regions, ${pe.fileEdges} file edges, " +
- s"${pe.regionEdges} region edges, ${pe.deleteOps} deletes)"
+ s"${pe.regionEdges} region edges, ${pe.deleteOps} deletes)" +
+ (if (bypassGuard) " [guard bypassed via --full]" else "")
)
- _ <- if (pe.totalOps > MaxSafePatchOps)
+ _ <- if (!bypassGuard && pe.totalOps > MaxSafePatchOps)
IO.raiseError(new MapCapacityException(
outcome = MapOutcome.LocalMapTooLarge,
userMessage = "Local map output is too large to persist safely.",
next = "For full system mapping at this scale, use Ix Cloud."
))
+ else if (bypassGuard && pe.totalOps > MaxSafePatchOps)
+ logger.info(
+ s"Persistence guard bypassed (--full): ${pe.totalOps} ops exceeds " +
+ s"limit of $MaxSafePatchOps, continuing anyway"
+ )
else IO.unit
_ <- submitMapPatch(oldRegions, regions, rev)
} yield pe