Skip to content

armgit / Ix

Public Imported from GitHub
0

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

merge: bring #680 (conflicts out of the evidence budget) under the usefulness gate

KageBinary426d7242c7aa
diff --cc ix-cli/src/cli/__tests__/context.test.ts
index 442c8be0,eee47ea6..4ef2ca22
--- a/ix-cli/src/cli/__tests__/context.test.ts
+++ b/ix-cli/src/cli/__tests__/context.test.ts
@@@ -339,9 -339,75 +339,75 @@@ describe("ix context bundle", () =>
expect(second.intents).toEqual(first.intents);
});
+ it("keeps conflicts out of the evidence list", () => {
+ const conflicts: ConflictReport[] = Array.from({ length: 8 }, (_, i) => ({
+ id: `c-${i}`,
+ claimA: `12e6db16-e88f-34d1-92ab-4d1700fd67a${i}`,
+ claimB: `494d48cd-fff5-37a9-93f5-060c0760c52${i}`,
+ reason: "Potential inconsistency (same field prefix)",
+ recommendation: "rec",
+ }));
+
+ const bundle = buildBundle({ ...input(), context: makeContext({ conflicts }) });
+
+ expect(bundle.evidence.some((item) => item.kind === "conflict")).toBe(false);
+ // A claim uuid is not something an agent can act on; none should be
+ // reachable through the evidence list at all.
+ const rendered = JSON.stringify(bundle.evidence);
+ expect(rendered).not.toContain("12e6db16");
+ // The reports themselves are still carried, and still counted.
+ expect(bundle.conflicts).toHaveLength(8);
+ });
+
+ it("leaves the evidence budget to real structure when conflicts are present", () => {
+ // The regression this exists for: 8 conflicts used to take 8 of the 10
+ // slots and push the structural facts out of the bundle entirely.
+ const conflicts: ConflictReport[] = Array.from({ length: 8 }, (_, i) => ({
+ id: `c-${i}`,
+ claimA: `claim-a-${i}`,
+ claimB: `claim-b-${i}`,
+ reason: "Potential inconsistency (same field prefix)",
+ recommendation: "rec",
+ }));
- const budgets = { maxEntities: 50, maxRelationships: 100, maxEvidence: 10, maxChars: 12000 };
++ const budgets = { maxEntities: 50, maxRelationships: 100, maxEvidence: 10, maxTokens: 1500, maxChars: 12000 };
+
+ const withConflicts = buildBundle({ ...input(), budgets, context: makeContext({ conflicts }) });
+ const without = buildBundle({ ...input(), budgets, context: makeContext() });
+
+ const structural = (b: typeof withConflicts) => b.evidence.filter((i) => i.kind === "structural").length;
+ expect(structural(withConflicts)).toBe(structural(without));
+ expect(structural(withConflicts)).toBeGreaterThan(0);
+ });
+
+ it("caps the conflict reports it carries and says how many it dropped", () => {
+ const conflicts: ConflictReport[] = Array.from({ length: 31 }, (_, i) => ({
+ id: `c-${String(i).padStart(2, "0")}`,
+ claimA: `claim-a-${String(i).padStart(2, "0")}`,
+ claimB: `claim-b-${String(i).padStart(2, "0")}`,
+ reason: "Potential inconsistency (same field prefix)",
+ recommendation: "rec",
+ }));
+
+ const bundle = buildBundle({ ...input(), context: makeContext({ conflicts }) });
+
+ expect(bundle.conflicts).toHaveLength(10);
+ expect(bundle.truncation.conflictsTruncated).toBe(21);
+ // Kept + dropped still reports the true count to the renderers.
+ expect(bundle.conflicts.length + bundle.truncation.conflictsTruncated).toBe(31);
+ // The cut is taken after the deterministic sort, so it is reproducible.
+ expect(bundle.conflicts.map((c) => c.claimA)).toEqual(
+ Array.from({ length: 10 }, (_, i) => `claim-a-${String(i).padStart(2, "0")}`),
+ );
+ });
+
+ it("reports no conflict truncation when the bundle is under the cap", () => {
+ const bundle = buildBundle({ ...input(), context: makeContext() });
+ expect(bundle.truncation.conflictsTruncated).toBe(0);
+ });
+
it("bounds evidence by the exact serialized representation, not an estimate", () => {
const claims = Array.from({ length: 60 }, (_, i) => makeClaim(`statement number ${i} with some padding text`, 0.5));
- const budgets = { maxEntities: 50, maxRelationships: 100, maxEvidence: 25, maxChars: 500 };
+ const budgets = { maxEntities: 50, maxRelationships: 100, maxEvidence: 25, maxTokens: 1500, maxChars: 500 };
const bundle = buildBundle({ ...input(), context: makeContext({ claims }), budgets });
diff --cc ix-cli/src/cli/commands/context.ts
index 01ee92a7,f4faade7..dc3c6e99
--- a/ix-cli/src/cli/commands/context.ts
+++ b/ix-cli/src/cli/commands/context.ts
@@@ -258,15 -210,7 +265,16 @@@ interface ContextBundle
relationshipsTruncated: number;
evidenceTruncated: number;
charactersTruncated: number;
+ conflictsTruncated: number;
+ /**
+ * What the budget dropped, by category, largest first.
+ *
+ * The counts above say how much went; this says what it was. "Rerun with
+ * larger --max-* budgets" was the same sentence for a file that lost 36 of
+ * its own members and for a symbol that lost two claims, and it named the
+ * one lever that costs the caller the most to pull.
+ */
+ cut?: Array<{ what: string; count: number }>;
};
metadata: {
asOfRev?: number;