Skip to content

armgit / Ix

Public Imported from GitHub
0

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

fix: record map completion for a workspace with no regions to build (#536)

KageBinary5898a8dba087
diff --git a/ix-cli/src/cli/__tests__/map-baseline.test.ts b/ix-cli/src/cli/__tests__/map-baseline.test.ts
index 3a3ff020..7f515699 100644
--- a/ix-cli/src/cli/__tests__/map-baseline.test.ts
+++ b/ix-cli/src/cli/__tests__/map-baseline.test.ts
@@ -56,6 +56,41 @@ describe("architecture map baseline", () => {
expect(hasCompletedMapBaseline(root)).toBe(true);
});
+ it("records a one-file workspace that has no regions to build", () => {
+ // The E2E fixture: one Python file, mapped as `1 files · 0s/0ss/0m
+ // regions`. There is no hierarchy to build over a single file and no
+ // later run will produce one, so refusing to record completion here
+ // leaves `ix doctor` unhealthy for ever, telling the user to run the
+ // command that just ran. `describeRegionlessCompletedMap` is what
+ // rejects a regionless map over real source; it needs two discovered
+ // files, which this workspace does not have.
+ const root = path.join(home, "one-file");
+ const filePath = path.join(root, "billing.py");
+ fs.mkdirSync(root, { recursive: true });
+ fs.writeFileSync(filePath, "class Billing:\n pass\n");
+ persistIngestBaselineIfClean(
+ root,
+ new Map([[filePath, fs.statSync(filePath).mtimeMs]]),
+ 1,
+ 0,
+ 0,
+ );
+
+ expect(
+ persistCompletedMapBaseline(
+ {
+ file_count: 1,
+ region_count: 0,
+ regions: [],
+ outcome: "full_local_completed",
+ },
+ root,
+ ),
+ ).toBe(true);
+
+ expect(hasCompletedMapBaseline(root)).toBe(true);
+ });
+
it.each(["local_map_too_large", "local_map_not_recommended"])(
"does not record the guardrail outcome %s",
(outcome) => {
diff --git a/ix-cli/src/cli/commands/map.ts b/ix-cli/src/cli/commands/map.ts
index da4557e4..24dc648f 100644
--- a/ix-cli/src/cli/commands/map.ts
+++ b/ix-cli/src/cli/commands/map.ts
@@ -218,13 +218,26 @@ export function invalidateBaselineForIncompleteCompletedMap(
return message;
}
-/** Persist hierarchy completion only when a non-empty map was actually produced. */
+/**
+ * Persist hierarchy completion only when a non-empty map was actually produced.
+ *
+ * "Non-empty" is the whole result, deliberately not the region count alone. A
+ * single-file workspace maps `1 files · 0s/0ss/0m regions` and that is
+ * finished, not partial — there is no hierarchy to build over one file, and no
+ * later `ix map` will produce one. Refusing to record it leaves `ix status`
+ * reading map_complete=false and `ix doctor` unhealthy for ever, with the
+ * suggested fix being the command that just ran.
+ *
+ * The regionless-with-real-source case is already rejected upstream by
+ * `describeRegionlessCompletedMap`, which returns before this is reached, and
+ * which knows the discovered-file count this function does not.
+ */
export function persistCompletedMapBaseline(
result: Pick<MapResult, "file_count" | "region_count" | "regions" | "outcome">,
projectRoot: string,
): boolean {
if (result.outcome && !COMPLETED_MAP_OUTCOMES.has(result.outcome)) return false;
- if (result.region_count === 0 && result.regions.length === 0) return false;
+ if (result.file_count === 0 && result.region_count === 0 && result.regions.length === 0) return false;
const sourceBaseline = loadIngestBaseline(projectRoot);
if (!sourceBaseline) return false;
return saveMapBaseline(projectRoot, sourceBaseline.currentRev);