Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/loopover-engine/src/focus-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
55 changes: 55 additions & 0 deletions test/unit/focus-manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
maintainerRecapConfigToJson,
opsConfigToJson,
publicStatsConfigToJson,
fairnessAnalyticsConfigToJson,
draftFlowConfigToJson,
upstreamDriftIssuesConfigToJson,
sweepWatchdogConfigToJson,
Expand Down Expand Up @@ -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({});
Expand Down