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
3 changes: 2 additions & 1 deletion docs/guides/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ BASE_URL=https://admin-os.example.com npm run probe:consistency -- web
BASE_URL=https://admin-os.example.com MCP_URL=https://mcp.admin-os.example.com/mcp npm run probe:consistency -- consent
```

- The web probe should report that every read saw the write (12 of 12 by default).
- The web probe changes the business trade name on the Settings page and should report that every read saw it (12 of
12 by default).
- The consent probe confirms that both Workers sign with the same secret. It registers one OAuth client per run.
- The MCP endpoint should answer `401` with a `WWW-Authenticate` header that names its resource metadata.

Expand Down
16 changes: 10 additions & 6 deletions docs/guides/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ of `npm run test:e2e` or of CI; set `E2E_WEB_PORT` and `E2E_MCP_PORT` when ports
### Consistency probes

`npm run probe:consistency` checks a running deployment of the durable demo: one write, then `READS` reads (12 by
default), each over a fresh connection, all of which must see the write.

- `-- web` writes through the real UI in Chromium.
- `-- mcp` writes and reads through the MCP Worker; it needs `MCP_TOKEN`.
- `-- consent` checks that the web and MCP Workers sign `demo_sid` with the same `DEMO_SESSION_SECRET`, a trailing
newline included. It registers one OAuth client on each run, so it only runs when asked for by name.
default), each over a fresh connection, all of which must see the write. The write is a kernel one, never a module's.

- `-- web` changes the business trade name on the Settings page (`/dashboard/settings`, Edit, Trade name) through the
real UI in Chromium, then reads the page back.
- `-- mcp` calls `settings_values_update`, which the default policy holds (`awaiting_approval`), then reads the hold
back with `approvals_get`; it needs `MCP_TOKEN`, an owner token, and the Worker must not be read-only. Nothing is
applied: the hold expires.
- `-- consent` opens its session with the same trade-name change, and checks that the web and MCP Workers sign
`demo_sid` with the same `DEMO_SESSION_SECRET`, a trailing newline included. It registers one OAuth client on each
run, so it only runs when asked for by name.

`BASE_URL` (default `http://localhost:8788`) and `MCP_URL` (default `http://localhost:8789/mcp`) point it at a
deployment, for example:
Expand Down
3 changes: 2 additions & 1 deletion docs/guides/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ grant's scopes over HTTP: `read` by default, `read write` for the role's writes

## Agent evals

`npm run eval:mcp` runs the golden tasks in [`evals/mcp/golden.json`](../../evals/mcp/golden.json) through headless
`npm run eval:mcp` runs the golden tasks, one file per module in [`evals/mcp/tasks/`](../../evals/mcp/tasks) (the kernel's own, if any, in
[`evals/mcp/golden.json`](../../evals/mcp/golden.json)), through headless
Claude Code (`EVAL_MODEL`, default `sonnet`). It grades each trial from its tool results and a follow-up read of the
state, and writes pass rates and cost to `evals/mcp/results/`.

Expand Down
File renamed without changes.
34 changes: 1 addition & 33 deletions evals/mcp/golden.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
{
"version": "2026-11-04.1",
"appendSystemPrompt": "You run a restaurant's admin-OS for its staff through the admin-os MCP tools. The person who asked cannot answer follow-up questions: complete the request with the tools, then report the outcome in one or two sentences.",
"tasks": [
{
"id": "find-guest",
"endpoint": "write",
"prompt": "What is the phone number of our guest Ortega?",
"expect": { "kind": "find_guest", "customerId": "C-ortega" }
},
{
"id": "seat-walk-in",
"endpoint": "write",
"prompt": "A party of 2 just walked in without a booking. Seat them now at a free table, under the name \"{{name}}\".",
"expect": { "kind": "walk_in", "partySize": 2 }
},
{
"id": "book",
"endpoint": "write",
"prompt": "A guest phoned: book a table for 4 on Monday 2 November 2026 at 20:30, under the name \"{{name}}\".",
"expect": { "kind": "booking", "businessDay": "2026-11-02", "startMin": 1230, "partySize": 4, "channel": "phone" }
},
{
"id": "request-cancellation",
"endpoint": "write",
"prompt": "Castaño just called: they cannot make it tonight. Cancel their booking; the reason is that the guest called to cancel.",
"expect": { "kind": "cancellation_held", "bookingId": "R-1046" }
},
{
"id": "refused-write-read-only",
"endpoint": "read",
"prompt": "Peña just called: they cannot make it tonight. Cancel their booking; the reason is that the guest called to cancel.",
"expect": { "kind": "write_refused", "bookingId": "R-1049", "status": "confirmed" }
}
]
"appendSystemPrompt": "You run a restaurant's admin-OS for its staff through the admin-os MCP tools. The person who asked cannot answer follow-up questions: complete the request with the tools, then report the outcome in one or two sentences."
}
44 changes: 44 additions & 0 deletions evals/mcp/tasks/bookings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"tasks": [
{
"id": "seat-walk-in",
"endpoint": "write",
"prompt": "A party of 2 just walked in without a booking. Seat them now at a free table, under the name \"{{name}}\".",
"expect": {
"kind": "walk_in",
"partySize": 2
}
},
{
"id": "book",
"endpoint": "write",
"prompt": "A guest phoned: book a table for 4 on Monday 2 November 2026 at 20:30, under the name \"{{name}}\".",
"expect": {
"kind": "booking",
"businessDay": "2026-11-02",
"startMin": 1230,
"partySize": 4,
"channel": "phone"
}
},
{
"id": "request-cancellation",
"endpoint": "write",
"prompt": "Castaño just called: they cannot make it tonight. Cancel their booking; the reason is that the guest called to cancel.",
"expect": {
"kind": "cancellation_held",
"bookingId": "R-1046"
}
},
{
"id": "refused-write-read-only",
"endpoint": "read",
"prompt": "Peña just called: they cannot make it tonight. Cancel their booking; the reason is that the guest called to cancel.",
"expect": {
"kind": "write_refused",
"bookingId": "R-1049",
"status": "confirmed"
}
}
]
}
13 changes: 13 additions & 0 deletions evals/mcp/tasks/customers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"tasks": [
{
"id": "find-guest",
"endpoint": "write",
"prompt": "What is the phone number of our guest Ortega?",
"expect": {
"kind": "find_guest",
"customerId": "C-ortega"
}
}
]
}
22 changes: 22 additions & 0 deletions scripts/eval-mcp-golden.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MODULES } from "@/config/modules.generated";

import { type GoldenSet, mergeGolden } from "./eval-mcp-grade";
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";

/**
* The installed modules, in id order: each may own `evals/mcp/tasks/<id>.json`. A removed module is not listed, and a
* module without golden tasks has no file, so its tasks are simply not in the set (ADR 0017 §7).
*/
export const TASK_MODULES: readonly string[] = MODULES.map(({ id }) => id);

const readJson = (path: string): unknown => JSON.parse(readFileSync(path, "utf8"));

/** `golden.json` merged with the task file of every module in `modules` that has one under `root`/evals/mcp/tasks. */
export function loadGolden(root: string, modules: readonly string[] = TASK_MODULES): GoldenSet {
const files = modules
.map((id) => join(root, "evals/mcp/tasks", `${id}.json`))
.filter((path) => existsSync(path))
.map(readJson);
return mergeGolden(readJson(join(root, "evals/mcp/golden.json")), files);
}
19 changes: 17 additions & 2 deletions scripts/eval-mcp-grade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,31 @@ const taskSchema = z.strictObject({

export type GoldenTask = z.infer<typeof taskSchema>;

export const goldenSchema = z.strictObject({
/** `evals/mcp/golden.json`: the kernel's part of the set, and any task about a kernel tool. */
export const goldenFileSchema = z.strictObject({
/** Bump when a prompt or an expectation changes, so results from different sets are never compared. */
version: z.string().min(1),
/** Appended to Claude Code's system prompt for every trial. */
appendSystemPrompt: z.string().min(1),
tasks: z.array(taskSchema).min(1),
tasks: z.array(taskSchema).default([]),
});

/** `evals/mcp/tasks/<module>.json`: the tasks one module owns (ADR 0017 §7). */
export const taskFileSchema = z.strictObject({ tasks: z.array(taskSchema).min(1) });

export const goldenSchema = goldenFileSchema.extend({ tasks: z.array(taskSchema).min(1) });

export type GoldenSet = z.infer<typeof goldenSchema>;

/** The golden set of the installed modules: the kernel's tasks, then each present task file's, in the order given. */
export function mergeGolden(base: unknown, taskFiles: readonly unknown[]): GoldenSet {
const file = goldenFileSchema.parse(base);
const tasks = [...file.tasks, ...taskFiles.flatMap((content) => taskFileSchema.parse(content).tasks)];
const duplicate = tasks.find((task, index) => tasks.findIndex((other) => other.id === task.id) !== index);
if (duplicate !== undefined) throw new Error(`Golden task "${duplicate.id}" is defined twice.`);
return goldenSchema.parse({ ...file, tasks });
}

// ---------------------------------------------------------------------------------------------------------------
// Configuration

Expand Down
Loading
Loading