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
49 changes: 49 additions & 0 deletions dashboard/src/api/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,7 @@ export interface components {
questions_log: components["schemas"]["QuestionsLogSettings"];
sign_in: components["schemas"]["SignInSettings"];
assistants: components["schemas"]["AssistantSettings"];
search_questions: components["schemas"]["SearchQuestionsSettings"];
/**
* Ai Provider
* @description The service an answer is written with. Null: none is used, search runs on this instance's own model, and nothing anybody asks is sent elsewhere
Expand Down Expand Up @@ -2604,6 +2605,54 @@ export interface components {
*/
effective_date: string;
};
/** SearchQuestionsLaw */
SearchQuestionsLaw: {
/**
* Law
* @description The law's slug
*/
law: string;
/**
* Short Name
* @description What people call the law, in English
*/
short_name: string;
/**
* Questions
* @description How many questions the law's file holds
*/
questions: number;
/**
* Current
* @description How many sit beside the words they were written for, and so are used. The rest wait to be written again for words that have changed
*/
current: number;
/**
* Written By
* @description The models that wrote them
*/
written_by: string;
/**
* Checked By
* @description The models that checked them
*/
checked_by: string;
/**
* Written On
* Format: date
*/
written_on: string;
};
/** SearchQuestionsSettings */
SearchQuestionsSettings: {
/**
* On
* @description Whether searches use the search questions, which only reorder the clauses a search found and are never returned. Changed with `dpolens search-questions on` or `off`, which the governance log records
*/
on: boolean;
/** Laws */
laws: components["schemas"]["SearchQuestionsLaw"][];
};
/** SearchRequest */
SearchRequest: {
/**
Expand Down
20 changes: 19 additions & 1 deletion dashboard/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,11 @@ export const en = {
update: "Loaded {{pack}} {{version}}, downloaded from {{repository}} on GitHub",
file: "Loaded {{pack}} {{version}}, imported from a file",
},
search_questions_loaded_one: "Loaded {{number}} search question for {{pack}}, written {{date}}",
search_questions_loaded_other:
"Loaded {{number}} search questions for {{pack}}, written {{date}}",
search_questions_on: "Turned the search questions on",
search_questions_off: "Turned the search questions off",
document_drafted: "Uploaded {{file}}, a draft of {{policy}}",
document_flag_accepted_one: "Accepted {{count}} flag in the draft of {{policy}}",
document_flag_accepted_other: "Accepted {{count}} flags in the draft of {{policy}}",
Expand Down Expand Up @@ -1201,7 +1206,7 @@ export const en = {
settings: {
title: "Settings",
subtitle:
"How this instance is set up. These are fixed when it starts, so changing one means a restart.",
"How this instance is set up. Most are fixed when it starts, so changing one means a restart.",
howTo: "How to change them",
questionsLog: "Questions log",
keptFor: "Kept for",
Expand Down Expand Up @@ -1237,6 +1242,19 @@ export const en = {
runsOn: "Search runs on",
ownModel: "This instance, on its own model",
nothingSent: "Nothing a person asks or reads here is sent to another service.",
searchQuestions: "Search questions",
searchQuestionsNote:
"Questions a model wrote beside each clause of a law, and another checked. They only reorder the clauses a search found, and are never shown. The command dpolens search-questions off turns them off, and the governance log records it.",
inSearches: "In searches",
used: "Used",
turnedOff: "Turned off",
questionsFor_one: "{{number}} question, written {{date}}",
questionsFor_other: "{{number}} questions, written {{date}}",
questionsStale_one: "{{number}} question, {{current}} current, written {{date}}",
questionsStale_other: "{{number}} questions, {{current}} of them current, written {{date}}",
writtenBy: "Written by",
checkedBy: "Checked by",
noQuestions: "No law has them loaded",
instance: "This instance",
version: "Version",
id: "Instance ID",
Expand Down
21 changes: 21 additions & 0 deletions dashboard/src/lib/governance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,24 @@ describe("a law's entries in the governance log", () => {
).toBe("Loaded GDPR 2026.1");
});
});

describe("the search questions' entries in the governance log", () => {
it("say how many were loaded for which law, and when they were written", () => {
expect(
sentence("search_questions.loaded", {
pack: "uae-pdpl",
questions: 1081,
written_on: "2026-11-07",
}),
).toBe("Loaded 1,081 search questions for UAE PDPL, written 7 November 2026");
});

it("say which way they were turned", () => {
expect(sentence("search_questions.switched", { before: true, after: false })).toBe(
"Turned the search questions off",
);
expect(sentence("search_questions.switched", { before: false, after: true })).toBe(
"Turned the search questions on",
);
});
});
13 changes: 12 additions & 1 deletion dashboard/src/lib/governance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TFunction } from "i18next";

import type { Entry } from "@/api/client";
import { formatDate } from "@/lib/format";
import { formatDate, formatNumber } from "@/lib/format";
import { wordsFor } from "@/lib/permissionWords";

type Details = Record<string, unknown>;
Expand Down Expand Up @@ -125,6 +125,17 @@ export function describeEntry(t: TFunction, entry: Entry): string {
}
case "laws.selection_cleared":
return t("entries.laws_selection_cleared");
case "search_questions.loaded": {
const count = Number(details.questions ?? 0);
return t("entries.search_questions_loaded", {
count,
number: formatNumber(count),
pack: law(details.pack ?? entry.target_id),
date: formatDate(text(details.written_on)),
});
}
case "search_questions.switched":
return t(details.after ? "entries.search_questions_on" : "entries.search_questions_off");
case "document.drafted":
return t("entries.document_drafted", { file: text(details.file), policy: policy(details) });
case "document.flag_accepted":
Expand Down
47 changes: 47 additions & 0 deletions dashboard/src/pages/Settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,53 @@ describe("settings", () => {
);
});

it("says whether searches use the search questions, and which laws have them", async () => {
serve({
"GET /v1/sessions/current": { body: admin },
"GET /v1/settings": { body: settings },
"GET /v1/governance/verification": { body: intact },
});
renderAt("/settings");

expect(await screen.findByText("Used")).toBeInTheDocument();
expect(screen.getByText("4,573 questions, written 7 November 2026")).toBeInTheDocument();
expect(screen.getByText("1,081 questions, written 7 November 2026")).toBeInTheDocument();
// Two laws by the same models name each model once.
expect(screen.getByText("claude-sonnet-5-5")).toBeInTheDocument();
expect(screen.getByText("claude-opus-5-5")).toBeInTheDocument();
});

it("says when the search questions are turned off, or some wait to be written again", async () => {
const [gdpr, uae] = settings.search_questions.laws;
serve({
"GET /v1/sessions/current": { body: admin },
"GET /v1/settings": {
body: {
...settings,
search_questions: { on: false, laws: [gdpr, { ...uae, current: 1000 }] },
},
},
"GET /v1/governance/verification": { body: intact },
});
renderAt("/settings");

expect(await screen.findByText("Turned off")).toBeInTheDocument();
expect(
screen.getByText("1,081 questions, 1,000 of them current, written 7 November 2026"),
).toBeInTheDocument();
});

it("says so when no law has search questions", async () => {
serve({
"GET /v1/sessions/current": { body: admin },
"GET /v1/settings": { body: { ...settings, search_questions: { on: true, laws: [] } } },
"GET /v1/governance/verification": { body: intact },
});
renderAt("/settings");

expect(await screen.findByText("No law has them loaded")).toBeInTheDocument();
});

it("says how long a question is kept when a retention is set", async () => {
serve({
"GET /v1/sessions/current": { body: admin },
Expand Down
36 changes: 36 additions & 0 deletions dashboard/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ function Group({ title, note, children }: { title: string; note?: string; childr
);
}

/** Each model once, though several laws may name it. */
function unique(names: string[]): string {
return [...new Set(names.flatMap((name) => name.split(", ")))].join(", ");
}

function CopyUrl({ value }: { value: string }) {
const { t } = useTranslation();
const [copied, setCopied] = useState(false);
Expand Down Expand Up @@ -158,6 +163,37 @@ export function SettingsPage() {
<Row label={t("settings.runsOn")}>{t("settings.ownModel")}</Row>
</Group>

<Group title={t("settings.searchQuestions")} note={t("settings.searchQuestionsNote")}>
<Row label={t("settings.inSearches")}>
{settings.data.search_questions.on ? t("settings.used") : t("settings.turnedOff")}
</Row>
{settings.data.search_questions.laws.map((law) => (
<Row key={law.law} label={law.short_name}>
{t(
law.current < law.questions ? "settings.questionsStale" : "settings.questionsFor",
{
count: law.questions,
number: formatNumber(law.questions),
current: formatNumber(law.current),
date: formatDate(law.written_on),
},
)}
</Row>
))}
{settings.data.search_questions.laws.length ? (
<>
<Row label={t("settings.writtenBy")}>
{unique(settings.data.search_questions.laws.map((law) => law.written_by))}
</Row>
<Row label={t("settings.checkedBy")}>
{unique(settings.data.search_questions.laws.map((law) => law.checked_by))}
</Row>
</>
) : (
<Row label={t("settings.searchQuestions")}>{t("settings.noQuestions")}</Row>
)}
</Group>

<Group title={t("settings.instance")}>
<Row label={t("settings.version")}>{settings.data.instance.version}</Row>
<Row label={t("settings.id")}>
Expand Down
23 changes: 23 additions & 0 deletions dashboard/src/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,29 @@ export const settings: InstanceSettings = {
wrong_password_window_minutes: 15,
},
assistants: { mcp_url: "https://dpolens.example.com/mcp", requests_per_minute: 60 },
search_questions: {
on: true,
laws: [
{
law: "gdpr",
short_name: "GDPR",
questions: 4573,
current: 4573,
written_by: "claude-sonnet-5-5",
checked_by: "claude-opus-5-5",
written_on: "2026-11-07",
},
{
law: "uae-pdpl",
short_name: "UAE PDPL",
questions: 1081,
current: 1081,
written_by: "claude-sonnet-5-5",
checked_by: "claude-opus-5-5",
written_on: "2026-11-07",
},
],
},
ai_provider: null,
instance: {
version: "0.1.0",
Expand Down
4 changes: 4 additions & 0 deletions docs/api-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ breaking change needs a new major version.
search, and still read by key
- `coming` holds the words an amendment gives a clause from a later day, with that
day and the amendment, when one does
- `GET /v1/settings` carries `search_questions`: whether searches use the search
questions, and for each law that has them how many it holds, how many are current,
which models wrote and checked them, and when. They are turned on and off with
`dpolens search-questions`, not through the API

## 0.2.0

Expand Down
76 changes: 76 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -8822,6 +8822,9 @@
"assistants": {
"$ref": "#/components/schemas/AssistantSettings"
},
"search_questions": {
"$ref": "#/components/schemas/SearchQuestionsSettings"
},
"ai_provider": {
"anyOf": [
{
Expand All @@ -8843,6 +8846,7 @@
"questions_log",
"sign_in",
"assistants",
"search_questions",
"ai_provider",
"instance"
],
Expand Down Expand Up @@ -10865,6 +10869,78 @@
],
"title": "ScheduledVersion"
},
"SearchQuestionsLaw": {
"properties": {
"law": {
"type": "string",
"title": "Law",
"description": "The law's slug"
},
"short_name": {
"type": "string",
"title": "Short Name",
"description": "What people call the law, in English"
},
"questions": {
"type": "integer",
"title": "Questions",
"description": "How many questions the law's file holds"
},
"current": {
"type": "integer",
"title": "Current",
"description": "How many sit beside the words they were written for, and so are used. The rest wait to be written again for words that have changed"
},
"written_by": {
"type": "string",
"title": "Written By",
"description": "The models that wrote them"
},
"checked_by": {
"type": "string",
"title": "Checked By",
"description": "The models that checked them"
},
"written_on": {
"type": "string",
"format": "date",
"title": "Written On"
}
},
"type": "object",
"required": [
"law",
"short_name",
"questions",
"current",
"written_by",
"checked_by",
"written_on"
],
"title": "SearchQuestionsLaw"
},
"SearchQuestionsSettings": {
"properties": {
"on": {
"type": "boolean",
"title": "On",
"description": "Whether searches use the search questions, which only reorder the clauses a search found and are never returned. Changed with `dpolens search-questions on` or `off`, which the governance log records"
},
"laws": {
"items": {
"$ref": "#/components/schemas/SearchQuestionsLaw"
},
"type": "array",
"title": "Laws"
}
},
"type": "object",
"required": [
"on",
"laws"
],
"title": "SearchQuestionsSettings"
},
"SearchRequest": {
"properties": {
"query": {
Expand Down
Loading
Loading