## Overview Adds a **Classification policy** to the processor's policy catalogue, set up the same way as the Security policy. This moves classifier configuration out of the editor (where the labels UI landed in #6898 and was then removed with the rest of the editor's policy-management surface in #6932) and into the processor, which is now the single place policies are configured. ## What it does - **Classification card** in the processor policy catalogue. Always shown, but **setup is locked until the backend reports the AI engine is on** — so admins can see the capability they're missing rather than it being hidden entirely. - **Setup wizard** mirrors Security: the workflow step shows the team's **classification label editor** (reused `LabelsEditor`/`LabelsEditorModal` — add box, chip grid, per-label icon picker, import/export, reset) instead of tool toggles, since classify is a single non-configurable step. - On enable, the team's label vocabulary is **seeded with the 268 built-in defaults** (clobber-safe: only when the team has none). On upload the document is classified against the team's labels and tagged; on SaaS with the engine on, files group by category in the editor sidebar. ## Reuse & consolidation - Reuses the existing labels table, `labelsFile` helpers, and default vocabulary. Labels read/write through the processor's own `apiClient.local` (not the editor's axios client) so auth/base routing stays explicit; the wire shape is shared. - Consolidates policy-category icons into a shared, **id-keyed** `policyCategoryIcon` util (outline glyphs) used by both the editor and the processor, replacing the processor's emoji-glyph map (and the stray `schedule` key that rendered a bare dot). ## Testing - `task frontend:typecheck:{core,proprietary,portal}`, `frontend:lint:eslint`, `frontend:test` (156 files / 1305 tests) — all green. - Verified in Storybook: the Classification card renders, the setup wizard shows the label editor (268 defaults), and the full labels editor opens with icons/import/export/reset. Added an MSW handler for the app-config + labels endpoints and a `Classification` wizard story. ## Notes for reviewers - The AI-engine gate reads the public `/api/v1/config/app-config`; classification labels use `/api/v1/classification/labels` (team-scoped, team-lead/admin-gated, `policies.enabled`); the classify step hits `/api/v1/ai/tools/classify-and-label` — all pre-existing backend from #6898. - Known parity behavior (matches the editor hook): a transient failure loading team labels falls back to showing the defaults; not changed here to avoid diverging the two hooks.
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import fs from "fs";
|
|
import path from "path";
|
|
import { describe, it, expect } from "vitest";
|
|
import { DEFAULT_CLASSIFICATION_LABELS } from "@app/data/classificationLabels";
|
|
|
|
// The classifier vocabulary is bundled in TWO places that must not drift:
|
|
// - this frontend JSON (source of truth for sidebar categories + display names)
|
|
// - a backend copy the classify tool sends to the AI engine per request
|
|
// (app/proprietary/src/main/resources/classification/classification-labels.json).
|
|
// The backend sends label IDS the engine stores on the document and the frontend
|
|
// then displays, so a divergence means the classifier picks a label the UI can't
|
|
// render (or the UI advertises labels the classifier never uses). This guards it.
|
|
|
|
const REPO_ROOT = path.resolve(__dirname, "../../../../..");
|
|
const BACKEND_LABELS_FILE = path.join(
|
|
REPO_ROOT,
|
|
"app/proprietary/src/main/resources/classification/classification-labels.json",
|
|
);
|
|
|
|
interface Label {
|
|
id: string;
|
|
name: string;
|
|
icon?: string | null;
|
|
}
|
|
|
|
function readBackendLabels(): Label[] {
|
|
const raw = JSON.parse(fs.readFileSync(BACKEND_LABELS_FILE, "utf8")) as {
|
|
labels: Label[];
|
|
};
|
|
return raw.labels;
|
|
}
|
|
|
|
describe("classification label vocabulary (frontend ↔ backend)", () => {
|
|
const frontend = DEFAULT_CLASSIFICATION_LABELS;
|
|
const backend = readBackendLabels();
|
|
|
|
it("has the identical set of label ids on both sides", () => {
|
|
const frontendIds = [...new Set(frontend.map((l) => l.id))].sort();
|
|
const backendIds = [...new Set(backend.map((l) => l.id))].sort();
|
|
expect(backendIds).toEqual(frontendIds);
|
|
});
|
|
|
|
it("has matching name and icon per id on both sides", () => {
|
|
const backendById = new Map(backend.map((l) => [l.id, l]));
|
|
for (const label of frontend) {
|
|
const other = backendById.get(label.id);
|
|
expect(other, `backend missing label "${label.id}"`).toBeDefined();
|
|
expect({ name: other!.name, icon: other!.icon ?? null }).toEqual({
|
|
name: label.name,
|
|
icon: label.icon ?? null,
|
|
});
|
|
}
|
|
});
|
|
});
|