From 00a6c0fe4e60811636b11bb84d22d29d0f460990 Mon Sep 17 00:00:00 2001 From: philluiz2323 Date: Fri, 24 Jul 2026 09:16:00 -0300 Subject: [PATCH] fix(engine): include fairnessAnalytics in parseFocusManifest's emptiness check parseFocusManifest's aggregate condition deciding whether to emit a "no recognized focus fields" warning and force manifest.present = false checks !manifest.X.present for every other optional block (gate, publicStats, draftFlow, ... federatedIntelligence), but omitted fairnessAnalytics even though it's parsed and assigned identically to every sibling. A .loopover.yml containing only a populated fairnessAnalytics: block was correctly parsed into { present: true, enabled: true } but then incorrectly forced back to manifest.present = false with a misleading empty-manifest warning, since the aggregate check never saw it. Added the missing !manifest.fairnessAnalytics.present term in the same position the field is parsed in (between publicStats and draftFlow). Added a dedicated fairnessAnalytics: test block mirroring the existing publicStats: suite -- this block had no test coverage at all before, including the specific regression case (fairnessAnalytics-only manifest stays present with no spurious warning). Fixes #8366 --- .../loopover-engine/src/focus-manifest.ts | 1 + test/unit/focus-manifest.test.ts | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/packages/loopover-engine/src/focus-manifest.ts b/packages/loopover-engine/src/focus-manifest.ts index 676ae101c8..c901206219 100644 --- a/packages/loopover-engine/src/focus-manifest.ts +++ b/packages/loopover-engine/src/focus-manifest.ts @@ -4019,6 +4019,7 @@ export function parseFocusManifest(raw: unknown, source?: FocusManifestSource): !manifest.maintainerRecap.present && !manifest.ops.present && !manifest.publicStats.present && + !manifest.fairnessAnalytics.present && !manifest.draftFlow.present && !manifest.upstreamDriftIssues.present && !manifest.sweepWatchdog.present && diff --git a/test/unit/focus-manifest.test.ts b/test/unit/focus-manifest.test.ts index 6ef8c3fd71..08d47b8ae3 100644 --- a/test/unit/focus-manifest.test.ts +++ b/test/unit/focus-manifest.test.ts @@ -43,6 +43,7 @@ import { maintainerRecapConfigToJson, opsConfigToJson, publicStatsConfigToJson, + fairnessAnalyticsConfigToJson, draftFlowConfigToJson, upstreamDriftIssuesConfigToJson, sweepWatchdogConfigToJson, @@ -2047,6 +2048,60 @@ describe("parseFocusManifest gate config", () => { }); }); + describe("fairnessAnalytics: (#fairness-analytics, internal contributor-trust-profile config-as-code override)", () => { + it("defaults to fully disabled/absent when the key is omitted, and does not make the manifest present on its own", () => { + const m = parseFocusManifest({}); + expect(m.fairnessAnalytics).toEqual({ present: false, enabled: false }); + expect(m.present).toBe(false); + }); + + it("treats an explicit null the same as an omitted key", () => { + expect(parseFocusManifest({ fairnessAnalytics: null }).fairnessAnalytics).toEqual({ present: false, enabled: false }); + }); + + it("warns and falls back to the default when the value is a non-mapping type (string or array)", () => { + const asString = parseFocusManifest({ fairnessAnalytics: "nope" as never }); + expect(asString.fairnessAnalytics.present).toBe(false); + expect(asString.warnings.some((w) => /"fairnessAnalytics" must be a mapping/.test(w))).toBe(true); + const asArray = parseFocusManifest({ fairnessAnalytics: ["nope"] as never }); + expect(asArray.fairnessAnalytics.present).toBe(false); + expect(asArray.warnings.some((w) => /"fairnessAnalytics" must be a mapping/.test(w))).toBe(true); + }); + + // Regression (#8366): a manifest whose ONLY recognized content is a populated fairnessAnalytics: + // block was incorrectly marked present: false, with a spurious "no recognized focus fields" warning + // -- the aggregate emptiness check omitted this block while every sibling was included. + it("parses enabled: true, making the manifest present with no spurious empty-manifest warning (#8366)", () => { + const m = parseFocusManifest({ fairnessAnalytics: { enabled: true } }); + expect(m.fairnessAnalytics).toEqual({ present: true, enabled: true }); + expect(m.present).toBe(true); + expect(m.warnings.some((w) => /no recognized focus fields/i.test(w))).toBe(false); + }); + + it("parses enabled: false explicitly, still marking the manifest present (present is a real override, off)", () => { + const m = parseFocusManifest({ fairnessAnalytics: { enabled: false } }); + expect(m.fairnessAnalytics).toEqual({ present: true, enabled: false }); + expect(m.present).toBe(true); + }); + + it("warns and defaults to false when enabled is a non-boolean value", () => { + const m = parseFocusManifest({ fairnessAnalytics: { enabled: "yes" as unknown as boolean } }); + expect(m.fairnessAnalytics.enabled).toBe(false); + expect(m.warnings.some((w) => /fairnessAnalytics\.enabled/.test(w))).toBe(true); + }); + + it("round-trips through fairnessAnalyticsConfigToJson → parseFocusManifest unchanged", () => { + const m = parseFocusManifest({ fairnessAnalytics: { enabled: true } }); + expect(parseFocusManifest({ fairnessAnalytics: fairnessAnalyticsConfigToJson(m.fairnessAnalytics) }).fairnessAnalytics).toEqual( + m.fairnessAnalytics, + ); + }); + + it("fairnessAnalyticsConfigToJson returns null for an absent config", () => { + expect(fairnessAnalyticsConfigToJson(parseFocusManifest(null).fairnessAnalytics)).toBeNull(); + }); + }); + describe("draftFlow: (#6275, fleet-wide AI-drafted-PR creation capability config-as-code override)", () => { it("defaults to fully disabled/absent when the key is omitted, and does not make the manifest present on its own", () => { const m = parseFocusManifest({});