Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Add a paginated Errors view to admin logs (#1047)

Regan Bell4535f0d0530b
diff --git a/docs/screenshots/admin-errors-pagination.png b/docs/screenshots/admin-errors-pagination.png
new file mode 100644
index 000000000..e633f44af
Binary files /dev/null and b/docs/screenshots/admin-errors-pagination.png differ
diff --git a/plugins/admin/public/index.html b/plugins/admin/public/index.html
index 290b8f31e..a6fd0a12a 100644
--- a/plugins/admin/public/index.html
+++ b/plugins/admin/public/index.html
@@ -1066,6 +1066,53 @@
color: var(--warn);
font-size: 12px;
}
+ .errors-table table {
+ table-layout: fixed;
+ min-width: 860px;
+ }
+ .errors-table th:nth-child(1) {
+ width: 10%;
+ }
+ .errors-table th:nth-child(2) {
+ width: 12%;
+ }
+ .errors-table th:nth-child(3) {
+ width: 16%;
+ }
+ .errors-table th:nth-child(4) {
+ width: 34%;
+ }
+ .errors-all th:nth-child(5) {
+ width: 18%;
+ }
+ .errors-scoped th:nth-child(4) {
+ width: 52%;
+ }
+ .errors-table th:last-child {
+ width: 10%;
+ }
+ .errors-table td {
+ white-space: normal;
+ overflow-wrap: anywhere;
+ }
+ .error-message {
+ min-width: 0;
+ white-space: normal;
+ overflow-wrap: anywhere;
+ }
+ .error-message summary {
+ cursor: pointer;
+ }
+ .error-message .error-full {
+ display: none;
+ white-space: pre-wrap;
+ }
+ .error-message[open] .error-preview {
+ display: none;
+ }
+ .error-message[open] .error-full {
+ display: inline;
+ }
.error-strip {
margin: 0 0 14px;
padding: 10px 12px;
@@ -6120,7 +6167,7 @@
const EFFECT_LABELS = { allow: "Allow", deny: "Deny", require_approval: "Require approval" };
const SECTIONS = [
{ views: ["governance", "models", "credentials", "connectors", "customize", "users"] },
- { label: "Logs", views: ["history", "slack", "judgments", "audit", "egress", "metrics"] },
+ { label: "Logs", views: ["history", "slack", "judgments", "errors", "audit", "egress", "metrics"] },
{ label: "Artifacts", views: ["files", "skills", "memory", "deployments", "crons", "retention"] },
];
@@ -6275,6 +6322,7 @@
files: "Files",
memory: "Memory",
live: "Live",
+ errors: "Errors",
audit: "Audit",
skills: "Skills",
crons: "Crons",
@@ -6294,6 +6342,7 @@
"memory",
"live",
"audit",
+ "errors",
"skills",
"crons",
"deployments",
@@ -6311,6 +6360,7 @@
]);
const ENDPOINT = { history: "sessions", files: "files", live: "runs" };
const HISTORY_PAGE_SIZE = 50;
+ const ERRORS_PAGE_SIZE = 50;
const TRANSCRIPT_PAGE_SIZE = 500;
const DEFAULT_VIEW = "history";
@@ -6948,6 +6998,7 @@
return q ? path + "?" + q : path;
}
if (st.scope && SCOPED.has(st.view)) p.set("scope", st.scope);
+ if (st.view === "errors" && st.page > 1) p.set("page", st.page);
if (st.principal) p.set("principal", st.principal);
if (st.view === "crons" && st.cron) p.set("cron", st.cron);
if (st.own && SCOPED.has(st.view)) p.set("own", st.own);
@@ -7003,7 +7054,10 @@
else if (session) resolvedView = "history";
return {
view: resolvedView,
- scope: pathScope || p.get("scope") || (resolvedView === "history" ? "org:" + orgId : scope),
+ scope:
+ pathScope ||
+ p.get("scope") ||
+ (resolvedView === "history" || resolvedView === "errors" ? "org:" + orgId : scope),
session,
turn: turnRaw == null || turnRaw === "" ? null : turnRaw,
principal: p.get("principal") || null,
@@ -7119,7 +7173,12 @@
});
}
function setView(v) {
- go({ view: v, scope: v === "history" ? "org:" + orgId : scope, session: null, historyKind: "conversation" });
+ go({
+ view: v,
+ scope: v === "history" || v === "errors" ? "org:" + orgId : scope,
+ session: null,
+ historyKind: "conversation",
+ });
}
document.querySelectorAll("[data-viewlink]").forEach((button) => {
button.onclick = () => setView(button.dataset.viewlink);
@@ -10884,6 +10943,7 @@
files: renderFiles,
memory: renderMemory,
live: renderLive,
+ errors: renderErrors,
audit: renderAudit,
skills: renderSkills,
crons: renderCrons,
@@ -10910,6 +10970,7 @@
}
if (historyKind === "background") path += "&origin=other_background";
}
+ if (view === "errors") path += `&limit=${ERRORS_PAGE_SIZE}&offset=${(page - 1) * ERRORS_PAGE_SIZE}`;
const cacheable = view !== "memory";
const cached = cacheable ? dataCache.get(path) : undefined;
if (cached !== undefined) {
@@ -11231,6 +11292,64 @@
),
);
}
+ function renderErrors(root, d) {
+ const all = orgWideView();
+ const errors = d.errors || [];
+ const total = d.total ?? errors.length;
+ const limit = d.limit || ERRORS_PAGE_SIZE;
+ const offset = d.offset || 0;
+ defaultShell({ count: plural(total, "error"), context: "Newest first" });
+ const rows = errors.map((e) => {
+ const scopeTarget = /^(personal|channel|team|org|group):.+/.test(e.scopeLabel || "") ? e.scopeLabel : null;
+ const fullText = e.message || "(no message)";
+ const previewText = firstLine(fullText, 160);
+ const expandable = previewText !== fullText;
+ const message = document.createElement(expandable ? "details" : "div");
+ message.className = "error-message";
+ if (expandable) {
+ const summary = document.createElement("summary");
+ const preview = document.createElement("span");
+ preview.className = "error-preview";
+ preview.textContent = previewText;
+ const full = document.createElement("span");
+ full.className = "error-full";
+ full.textContent = fullText;
+ summary.append(preview, full);
+ message.append(summary);
+ } else {
+ message.textContent = fullText;
+ }
+ return [
+ timeCell(e.ts),
+ { text: e.category || "uncategorized" },
+ { text: e.code || "—", cls: "mono" },
+ nodeCell(message),
+ ...(all
+ ? [
+ scopeTarget
+ ? nodeCell(navLink(shortName(scopeTarget), { view: "errors", scope: scopeTarget }))
+ : { text: e.scopeLabel || "System" },
+ ]
+ : []),
+ e.sessionId
+ ? nodeCell(
+ navLink("View session", { view: "history", scope: scopeTarget || scope, session: e.sessionId }),
+ )
+ : { text: "—" },
+ ];
+ });
+ const content = table(
+ ["Time", "Category", "Code", "Message", ...(all ? ["Scope"] : []), "Session"],
+ rows,
+ all ? "No errors recorded." : "No errors recorded for this scope.",
+ );
+ content.classList.add("errors-table", all ? "errors-all" : "errors-scoped");
+ const navigate = (n) => go({ view: "errors", scope, page: n });
+ root.appendChild(pager(total, limit, offset, navigate));
+ root.appendChild(bareDataCard(content));
+ root.appendChild(pager(total, limit, offset, navigate));
+ }
+
function renderAudit(root, d) {
const all = orgWideView();
const events = d.events || [];
diff --git a/plugins/admin/test/default-view.test.ts b/plugins/admin/test/default-view.test.ts
index fe7cce21f..21a12ffb0 100644
--- a/plugins/admin/test/default-view.test.ts
+++ b/plugins/admin/test/default-view.test.ts
@@ -48,7 +48,7 @@ test("admin shell uses the QM identity with org-injectable branding", () => {
test("admin shell groups control, logs, and artifacts like the reorganization", () => {
assert.match(
html,
- /const SECTIONS = \[\s*\{ views: \["governance", "models", "credentials", "connectors", "customize", "users"\] \},\s*\{ label: "Logs", views: \["history", "slack", "judgments", "audit", "egress", "metrics"\] \},\s*\{ label: "Artifacts", views: \["files", "skills", "memory", "deployments", "crons", "retention"\] \},\s*\];/,
+ /const SECTIONS = \[\s*\{ views: \["governance", "models", "credentials", "connectors", "customize", "users"\] \},\s*\{ label: "Logs", views: \["history", "slack", "judgments", "errors", "audit", "egress", "metrics"\] \},\s*\{ label: "Artifacts", views: \["files", "skills", "memory", "deployments", "crons", "retention"\] \},\s*\];/,
);
assert.match(html, /history: "Sessions"/);
assert.match(
diff --git a/plugins/admin/test/errors-view.test.ts b/plugins/admin/test/errors-view.test.ts
new file mode 100644
index 000000000..79e72d661
--- /dev/null
+++ b/plugins/admin/test/errors-view.test.ts
@@ -0,0 +1,97 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+
+const html = readFileSync(new URL("../public/index.html", import.meta.url), "utf8");
+const source = html.match(/function renderErrors\(root, d\) \{[\s\S]*?\n {6}\}/)?.[0];
+assert.ok(source);
+
+function render(all: boolean, errors: unknown[]) {
+ let result: { headers: string[]; rows: any[][]; empty: string };
+ const element = (tag: string) => ({
+ tag,
+ children: [] as any[],
+ append(...nodes: any[]) {
+ this.children.push(...nodes);
+ },
+ });
+ new Function(
+ "orgWideView",
+ "defaultShell",
+ "plural",
+ "document",
+ "firstLine",
+ "timeCell",
+ "nodeCell",
+ "navLink",
+ "shortName",
+ "bareDataCard",
+ "table",
+ "scope",
+ "ERRORS_PAGE_SIZE",
+ "pager",
+ `${source}; renderErrors({appendChild() {}}, arguments[14]);`,
+ )(
+ () => all,
+ () => {},
+ (n: number) => String(n),
+ { createElement: element },
+ (s: string, max: number) => s.split("\n")[0].slice(0, max),
+ (ts: number) => ts,
+ (node: unknown) => ({ node }),
+ (label: string, target: unknown) => ({ label, target }),
+ (scope: string) => scope,
+ (node: unknown) => node,
+ (headers: string[], rows: any[][], empty: string) => {
+ result = { headers, rows, empty };
+ return { classList: { add() {} } };
+ },
+ "org:acme",
+ 50,
+ () => ({}),
+ { errors },
+ );
+ return result!;
+}
+
+test("error rows preserve full text and link to the owning scope and session", () => {
+ const message = "<img src=x onerror=alert(1)>\nfull diagnostic";
+ const result = render(true, [
+ { ts: 123, category: "turn", code: "failed", message, scopeLabel: "personal:alice", sessionId: "session-1" },
+ ]);
+ assert.deepEqual(result.headers, ["Time", "Category", "Code", "Message", "Scope", "Session"]);
+ const details = result.rows[0][3].node;
+ assert.equal(details.tag, "details");
+ const [preview, full] = details.children[0].children;
+ assert.equal(preview.textContent, message.split("\n")[0]);
+ assert.equal(full.tag, "span");
+ assert.equal(full.textContent, message);
+ assert.equal(full.innerHTML, undefined);
+ assert.deepEqual(result.rows[0][4].node.target, { view: "errors", scope: "personal:alice" });
+ assert.deepEqual(result.rows[0][5].node.target, { view: "history", scope: "personal:alice", session: "session-1" });
+});
+
+test("scope errors omit the scope column and errors without sessions have no session link", () => {
+ const result = render(false, [{ ts: 123, scopeLabel: "org:acme", message: "failure" }]);
+ assert.equal(result.headers.includes("Scope"), false);
+ assert.deepEqual(result.rows[0].at(-1), { text: "—" });
+ assert.equal(render(false, []).empty, "No errors recorded for this scope.");
+ assert.equal(render(true, []).empty, "No errors recorded.");
+});
+
+test("system attribution stays readable without creating an invalid scope link", () => {
+ const result = render(true, [{ ts: 123, scopeLabel: "runs:reaper", message: "requeued", sessionId: "s1" }]);
+ assert.deepEqual(result.rows[0][4], { text: "runs:reaper" });
+ assert.deepEqual(result.rows[0][5].node.target, { view: "history", scope: "org:acme", session: "s1" });
+});
+
+test("short messages have no disclosure and long messages retain their full text", () => {
+ const short = render(true, [{ message: "Timed out" }]).rows[0][3].node;
+ assert.equal(short.tag, "div");
+ assert.equal(short.textContent, "Timed out");
+ assert.equal(short.children.length, 0);
+ const message = "x".repeat(200);
+ const long = render(true, [{ message }]).rows[0][3].node;
+ assert.equal(long.tag, "details");
+ assert.equal(long.children[0].children[1].textContent, message);
+});
diff --git a/plugins/admin/test/history-urls.test.ts b/plugins/admin/test/history-urls.test.ts
index 50b7e9a29..5cfd6ea38 100644
--- a/plugins/admin/test/history-urls.test.ts
+++ b/plugins/admin/test/history-urls.test.ts
@@ -26,8 +26,21 @@ function routerAt(pathname: string, search = "", base = "/admin") {
);
return factory(
base,
- new Set(["history", "files", "memory", "live", "audit", "skills", "crons", "deployments"]),
- ["history", "files", "memory", "live", "audit", "skills", "crons", "deployments", "slack", "judgments", "user"],
+ new Set(["history", "files", "memory", "live", "audit", "errors", "skills", "crons", "deployments"]),
+ [
+ "history",
+ "files",
+ "memory",
+ "live",
+ "audit",
+ "errors",
+ "skills",
+ "crons",
+ "deployments",
+ "slack",
+ "judgments",
+ "user",
+ ],
"history",
(scopeId: string) => String(scopeId || "").split(":")[0] || "scope",
{ pathname, search },
@@ -151,3 +164,20 @@ test("a bare history URL is the org scope, not whatever scope was viewed last",
const files = routerAt("/admin/files").urlToState();
assert.equal(files.scope, "channel:LAST-VIEWED");
});
+
+test("Errors opens org-wide and preserves explicit scope deep links", () => {
+ const router = routerAt("/admin/errors");
+ assert.equal(router.urlToState().view, "errors");
+ assert.equal(router.urlToState().scope, "org:acme");
+ assert.equal(router.stateToUrl({ view: "errors", scope: SCOPE }), `/admin/errors?scope=${SCOPE_ENC}`);
+ assert.equal(routerAt("/admin/errors", `?scope=${SCOPE_ENC}`).urlToState().scope, SCOPE);
+});
+
+test("Errors pagination round-trips arbitrary pages without losing scope", () => {
+ const router = routerAt("/admin/errors", `?scope=${SCOPE_ENC}&page=37`);
+ assert.equal(router.urlToState().page, 37);
+ assert.equal(
+ router.stateToUrl({ view: "errors", scope: SCOPE, page: 37 }),
+ `/admin/errors?scope=${SCOPE_ENC}&page=37`,
+ );
+});
diff --git a/src/admin/error-log.ts b/src/admin/error-log.ts
index 4607cba0c..5fe8e9fdf 100644
--- a/src/admin/error-log.ts
+++ b/src/admin/error-log.ts
@@ -13,7 +13,7 @@ export interface ErrorEvent {
export interface ErrorLog {
record(e: Omit<ErrorEvent, "ts">): void;
flush(): Promise<void>;
- list(opts?: { scopeId?: string; sessionId?: string; limit?: number }): Promise<ErrorEvent[]>;
+ list(opts?: { scopeId?: string; sessionId?: string; limit?: number; offset?: number }): Promise<ErrorEvent[]>;
count(opts?: { scopeId?: string; sessionId?: string }): Promise<number>;
}
diff --git a/src/admin/scoped-event-sink.ts b/src/admin/scoped-event-sink.ts
index 95df3cea5..598f419cf 100644
--- a/src/admin/scoped-event-sink.ts
+++ b/src/admin/scoped-event-sink.ts
@@ -9,6 +9,7 @@ export interface ScopedEvent {
interface ScopedEventQuery<E> {
scopeId?: string;
limit?: number;
+ offset?: number;
filter?: (e: E) => boolean;
}
@@ -38,14 +39,14 @@ export function createScopedEventSink<E extends ScopedEvent, In>(
return events
.filter((e) => (query.scopeId ? e.scopeLabel === query.scopeId : true))
.filter((e) => (query.filter ? query.filter(e) : true))
- .slice(-limit)
- .reverse();
+ .reverse()
+ .slice(query.offset ?? 0, (query.offset ?? 0) + limit);
},
all: () => events,
};
}
-type TimestampedQuery = { scopeId?: string; since?: number; limit?: number; [k: string]: unknown };
+type TimestampedQuery = { scopeId?: string; since?: number; limit?: number; offset?: number; [k: string]: unknown };
export interface TimestampedEventSink<E extends ScopedEvent & { ts: number }> {
record(input: Omit<E, "ts">): void;
@@ -70,6 +71,7 @@ export function createTimestampedEventSink<E extends ScopedEvent & { ts: number
sink.list({
...(opts.scopeId !== undefined ? { scopeId: opts.scopeId } : {}),
...(opts.limit !== undefined ? { limit: opts.limit } : {}),
+ ...(opts.offset !== undefined ? { offset: opts.offset } : {}),
filter: (e) =>
(opts.since === undefined || e.ts >= opts.since) &&
(cfg.equalityFields ?? []).every((f) => opts[f] === undefined || e[f] === opts[f]),
@@ -203,8 +205,9 @@ export function createPostgresEventSink<E>(cfg: PostgresEventSinkConfig<E>): Pos
const opts = input as Record<string, unknown>;
const { where, params } = buildWhere(opts);
params.push(opts.limit ?? cfg.defaultLimit);
+ params.push(opts.offset ?? 0);
const rows = await q(
- `SELECT ${dbCols} FROM ${cfg.table} ${where} ORDER BY ts DESC, id DESC LIMIT $${params.length}`,
+ `SELECT ${dbCols} FROM ${cfg.table} ${where} ORDER BY ts DESC, id DESC LIMIT $${params.length - 1} OFFSET $${params.length}`,
params,
);
return rows.map(toEvent);
diff --git a/src/api/routes/admin/observability.ts b/src/api/routes/admin/observability.ts
index c2db92e94..c9daa42d2 100644
--- a/src/api/routes/admin/observability.ts
+++ b/src/api/routes/admin/observability.ts
@@ -312,21 +312,25 @@ export async function listAdminErrors(ctx: ApiCtx): Promise<void> {
audit(deps, { principalId: actor.id, action: "errors.read", resource: "errors", scopeLabel: scope });
const orgWide = parseScopeId(scope).kind === "org";
const sessionId = url.searchParams.get("sessionId") || undefined;
- if (url.searchParams.get("count")) {
- const total =
- (await deps.errors?.count({
- ...(orgWide ? {} : { scopeId: scope }),
- ...(sessionId ? { sessionId } : {}),
- })) ?? 0;
- return sendJson(res, 200, { scopeId: scope, total });
+ const filters = {
+ ...(orgWide ? {} : { scopeId: scope }),
+ ...(sessionId ? { sessionId } : {}),
+ };
+ const rawLimit = Number(url.searchParams.get("limit") ?? ERRORS_LIST_LIMIT);
+ const rawOffset = Number(url.searchParams.get("offset") ?? 0);
+ if (!Number.isSafeInteger(rawLimit) || rawLimit < 1 || !Number.isSafeInteger(rawOffset) || rawOffset < 0) {
+ return sendJson(res, 400, {
+ error: "bad_request",
+ message: "limit must be a positive integer and offset a non-negative integer.",
+ });
}
- const fromLog =
- (await deps.errors?.list({
- ...(orgWide ? {} : { scopeId: scope }),
- ...(sessionId ? { sessionId } : {}),
- })) ?? [];
- const errors = [...fromLog].sort((a, b) => b.ts - a.ts).slice(0, ERRORS_LIST_LIMIT);
- return sendJson(res, 200, { scopeId: scope, errors });
+ const limit = Math.min(rawLimit, ERRORS_LIST_LIMIT);
+ const total = (await deps.errors?.count(filters)) ?? 0;
+ if (url.searchParams.get("count")) return sendJson(res, 200, { scopeId: scope, total });
+ const lastOffset = total ? Math.floor((total - 1) / limit) * limit : 0;
+ const offset = Math.min(rawOffset, lastOffset);
+ const errors = (await deps.errors?.list({ ...filters, limit, offset })) ?? [];
+ return sendJson(res, 200, { scopeId: scope, errors, total, limit, offset });
}
export async function listAdminAudit(ctx: ApiCtx): Promise<void> {
diff --git a/test/admin-observability.test.ts b/test/admin-observability.test.ts
index f9bd8c67a..b3425079b 100644
--- a/test/admin-observability.test.ts
+++ b/test/admin-observability.test.ts
@@ -1691,3 +1691,33 @@ test("the Auto flagger test run replays real screenings and reports a flag rate,
await new Promise<void>((r) => server.close(() => r()));
}
});
+
+test("admin errors paginate all retained records with scoped totals and bounded page sizes", async () => {
+ const s = start();
+ try {
+ for (let i = 0; i < 260; i++)
+ s.built.errors.record({
+ category: "turn",
+ code: String(i),
+ message: "failure",
+ scopeLabel: "personal:U1",
+ sessionId: "test-session",
+ });
+ s.built.errors.record({ category: "turn", code: "other", message: "failure", scopeLabel: "personal:U2" });
+ const path = "/v1/admin/errors?scope=personal:U1&sessionId=test-session";
+ const page = await getJson(s.base, path + "&limit=50&offset=200");
+ assert.equal(page.total, 260);
+ assert.equal(page.offset, 200);
+ assert.equal(page.errors.length, 50);
+ assert.equal(page.errors[0].code, "59");
+ const last = await getJson(s.base, path + "&limit=50&offset=999");
+ assert.equal(last.offset, 250);
+ assert.equal(last.errors.length, 10);
+ assert.equal((await getJson(s.base, path + "&limit=999")).limit, 200);
+ for (const query of ["limit=-1", "offset=-1", "offset=1.5", "limit=Infinity", "offset=NaN"])
+ assert.equal((await get(s.base, path + "&" + query)).status, 400);
+ assert.equal((await getJson(s.base, path + "&count=1")).total, 260);
+ } finally {
+ await s.close();
+ }
+});
diff --git a/test/postgres-error-log.test.ts b/test/postgres-error-log.test.ts
index f88d40fc8..9f6bd40f8 100644
--- a/test/postgres-error-log.test.ts
+++ b/test/postgres-error-log.test.ts
@@ -71,3 +71,22 @@ test("pg error log: flush makes writes visible to another process", { skip }, as
await writer.flush();
assert.equal((await reader.list({ sessionId: "sess-cross-process" })).length, 1);
});
+
+test("pg error log pages equal-timestamp records deterministically beyond 200", { skip }, async () => {
+ const pg = (await import("pg")).default;
+ const pool = new pg.Pool({ connectionString: URL });
+ try {
+ await pool.query(
+ "INSERT INTO error_events(ts, scope_label, category, code, message, session_id) SELECT 123, 'personal:pagination', 'turn', n::text, 'failure', 'pagination' FROM generate_series(0,259) n",
+ );
+ const log = createPostgresErrorLog(URL!);
+ const page = await log.list({ scopeId: "personal:pagination", sessionId: "pagination", limit: 50, offset: 200 });
+ assert.equal(page.length, 50);
+ assert.equal(page[0]?.code, "59");
+ assert.equal(page.at(-1)?.code, "10");
+ assert.equal((await log.list({ scopeId: "personal:pagination", offset: 250, limit: 50 })).length, 10);
+ assert.equal(await log.count({ scopeId: "personal:pagination" }), 260);
+ } finally {
+ await pool.end();
+ }
+});
diff --git a/test/scoped-event-sink.test.ts b/test/scoped-event-sink.test.ts
index e2caeee75..b0bfbec4d 100644
--- a/test/scoped-event-sink.test.ts
+++ b/test/scoped-event-sink.test.ts
@@ -82,3 +82,17 @@ test("audit log is now bounded (latent leak fixed) and preserves insertion order
assert.equal(events[0]?.at, 1, "oldest event dropped");
assert.equal(events[events.length - 1]?.at, 50000, "newest retained, oldest-first order");
});
+
+test("error log pages beyond the former 200-record window after filtering", async () => {
+ const log = createErrorLog();
+ for (let i = 0; i < 260; i++)
+ log.record({ category: "turn", code: String(i), message: "failure", scopeLabel: s1, sessionId: "one" });
+ log.record({ category: "turn", code: "other", message: "failure", scopeLabel: s2 });
+ const page = await log.list({ scopeId: s1, sessionId: "one", offset: 200, limit: 50 });
+ assert.equal(page.length, 50);
+ assert.equal(page[0]?.code, "59");
+ assert.equal(page.at(-1)?.code, "10");
+ assert.equal((await log.list({ scopeId: s1, offset: 250, limit: 50 })).length, 10);
+ assert.equal((await log.list({ scopeId: s1, offset: 260, limit: 50 })).length, 0);
+ assert.equal(await log.count({ scopeId: s1 }), 260);
+});