Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Opt-in and MCP train: one CHANGELOG entry, since TBD on the remote think row, regenerated goldens

garrytan20921a194859
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88200f75bd..16fcceada5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,9 +12,13 @@ identifiers and attribution are available in the pre-removal Git revision
## [Unreleased]
+**You can now cap the MCP request log's size without losing the dashboard's totals or the audit trail.** `gbrain serve --http` writes one `mcp_request_log` row for every call, `tools/list` included, and nothing ever deleted them, so a busy brain's log grew without limit. Retention is opt-in and off by default, so nothing changes until you run `gbrain config set cycle.purge.mcp_request_log_retention_days 90` (30 to 3650 days; 1 to 29 is refused because the built-in usage reports look back 30 days). Then the nightly cycle deletes request rows older than the window, and a PGLite brain held by a live `gbrain serve` prunes itself once an hour in short batches. The `surface_change`, `memory_setting_change` and `access_admin` audit rows are never deleted, and each pruned row is counted per client first, so the Agents page's total requests and last-used times stay exact. A usage report whose window reaches back past deleted history says so: `gbrain auth clients --usage` names the `--days` that is complete, the advisor skips its "starter op unused for 90 days" half, and `scripts/derive-starter-ops.ts` refuses. Deleted request detail cannot be restored. `gbrain doctor` reports the log's size and suggests turning retention on once it passes about 1M rows or 1 GiB, asking you first. Proposed and first implemented by @lubosxyz (#6770).
+
+**A remote `think` now runs on the brain host's own think model unless the host allows the model the caller asked for.** Every `think` answer is a paid call on the host's key, and before this change any MCP or HTTP client (or a thin-client `gbrain think --model`) could pick the most expensive model the host could reach. Now the requested `model` runs only when it is the host's think model (`models.think`, then `models.default`) or the host lists it in the new `think.remote_models` key (comma-separated, empty by default). Any other model, or a listed one the host cannot run (no key for its provider, or no chat support), no longer fails the call: the host model answers, `warnings` carries `MODEL_OVERRIDE_IGNORED:not_allowed` or `MODEL_OVERRIDE_IGNORED:unusable`, and the result carries a `model_override_ignored` notice that says how the owner can allow it. Remote `rounds` runs one round. The local CLI `--model` is unchanged and still exits 1 on an unusable model. A keyless brain answers a remote think the same way with or without `model`.
+
**Moved your brain folder? gbrain now tells you how to bring it back.** When a managed checkout was moved to a new path, or a folder above it was renamed, `gbrain sources set-path` and `gbrain sources add` used to refuse with a generic "identity changed" or "checkout missing" error that offered no way out, and their `--dry-run` said everything was fine. Now the preview and the real command refuse the same way, name where gbrain recorded the folder and where it is now, and give the exact commands that get you back without losing the folder's ownership or Git history. Nothing new can rebind ownership: the commands are the ones that already worked, and gbrain still checks everything they do.
-### How to use it
+### A moved brain folder: how to use it
Run the command you were going to run, with `--dry-run`:
@@ -31,7 +35,7 @@ The refusal (`recovery_required`, detail `physical_root_moved`) carries its exit
| A parent folder renamed | the same, on the parent folder |
| Copied to another disk and the original deleted | restore the original, or switch to classic mode (`gbrain sources writer deactivate --dry-run`); a copy cannot be reattached |
-### Things to watch
+### A moved brain folder: things to watch
- `gbrain sources add --dry-run` and `gbrain sources writer claim --dry-run` now refuse a folder that holds a copied ownership stamp, and `gbrain sources set-path --dry-run` refuses a missing checkout, as their real runs always did. They still write nothing.
- A remote agent whose page write reaches such a folder sees only the detail, never a path.
@@ -41,30 +45,11 @@ Proposed and first implemented by @Kkkkkuro (#8625).
### Itemized changes
-- `src/core/persistence/physical-root-record.ts`: `describeMovedPhysicalRoot` (read-only file evidence: the stamp's recorded root is gone, and the reservation of that root, beside it or beside the new root after a parent rename, carries the stamp's token, brain and worktree; `sameDirectory` from device, inode and birth time), `physicalRootMovedError` (path-free) and `physicalRootMovedRefusal` (the local CLI refusal with an `ask_user` fix chain in argv form, paths shell-quoted in the prose). An ownership stamp other users can read at the new path now refuses `ownership_record_not_private` instead of the generic error.
-- `src/core/persistence/physical-root.ts`: `movedPhysicalRoot` accepts the evidence only for this brain, a worktree this host owns and a host binding still at the recorded root; `reservePhysicalRoot` raises the path-free refusal on its copied-marker branch.
-- `src/core/persistence/source-lifecycle.ts`, `topology-locks.ts`, `administration.ts`: `add`, `claim`, `rebind` and `writer claim` build the full refusal (never for the automatic first-write claim); their dry runs predict it, and a rebind dry run of a missing checkout refuses `source_checkout_missing` like the real run.
-- `src/core/persistence/verb-errors.ts`, `src/core/error-registry.ts`: the `physical_root_moved` reason and its explanation; `docs/guides/error-codes.md` regenerated.
-- Docs: `docs/architecture/topologies.md#moved-root`, `docs/guides/write-refusals.md#moved-root`.
-- Tests: `test/physical-root-moved-8625.test.ts` (PGLite and Postgres: leaf and parent moves, bound and removed sources, Git and plain directories, a copy on a new inode, two sources in one worktree, `writer claim --dry-run`, five lookalikes that keep the generic refusal, a readable stamp, the classic keyless set-path, and a remote `put_page` whose refusal carries no path or worktree id).
-
-**A remote `think` now runs on the brain host's own think model unless the host allows the model the caller asked for.** Every `think` answer is a paid call on the host's key, and before this change any MCP or HTTP client (or a thin-client `gbrain think --model`) could pick the most expensive model the host could reach. Now the requested `model` runs only when it is the host's think model (`models.think`, then `models.default`) or the host lists it in the new `think.remote_models` key (comma-separated, empty by default). Any other model, or a listed one the host cannot run (no key for its provider, or no chat support), no longer fails the call: the host model answers, `warnings` carries `MODEL_OVERRIDE_IGNORED:not_allowed` or `MODEL_OVERRIDE_IGNORED:unusable`, and the result carries a `model_override_ignored` notice that says how the owner can allow it. Remote `rounds` runs one round. The local CLI `--model` is unchanged and still exits 1 on an unusable model. A keyless brain answers a remote think the same way with or without `model`.
-
-### Itemized changes
-
-- `src/core/ops/takes.ts`: `remoteThinkModel` resolves the requested model, the host think model and each `think.remote_models` entry through the same alias resolution and normalization, then runs the requested model only when it is the host model, or when it is listed, passes `probeChatModel` and has its provider's key. For remote callers, the #1698 explicit-model error no longer applies and `rounds` is 1.
-- `src/core/interop-notices.ts`, `src/core/error-registry.ts`: the `model_override_ignored` info notice (per session for each reason); for `not_allowed` its fix is `gbrain config set think.remote_models <models>` on the brain host (paid consent).
-- `src/commands/think.ts`: the thin client turns the server's `MODEL_OVERRIDE_IGNORED:*` warning into the same notice, and `--model` help says what a thin client gets.
-- `src/core/config-runtime-keys.ts`: `think.remote_models` is a registered key; no remote operation writes config, so only the host sets it.
-- `src/core/behavior-change-notice.ts`: one row for the remote `think` model rule. Docs: `docs/guides/remote-mcp.md` security posture.
-- Tests: `test/think-remote-model.test.ts` (PGLite and Postgres, remote MCP dispatch on a repo-less brain): an unlisted model, a listed model, a listed model the host cannot run, a listed model whose provider key the host lacks, the host model named explicitly, remote `rounds`, the local operation keeping #1698, and a keyless brain with and without `model`; `test/think-remote-model-thin-client.serial.test.ts`: the thin-client `--model` notice; `test/think-pipeline.test.ts` pins the #1698 error on the local caller and no error for a remote one.
-
-**You can now cap the MCP request log's size without losing the dashboard's totals or the audit trail.** `gbrain serve --http` writes one `mcp_request_log` row for every call, `tools/list` included, and nothing ever deleted them, so a busy brain's log grew without limit. Retention is opt-in and off by default, so nothing changes until you run `gbrain config set cycle.purge.mcp_request_log_retention_days 90` (30 to 3650 days; 1 to 29 is refused because the built-in usage reports look back 30 days). Then the nightly cycle deletes request rows older than the window, and a PGLite brain held by a live `gbrain serve` prunes itself once an hour in short batches. The `surface_change` and `memory_setting_change` audit rows are never deleted, and each pruned row is counted per client first, so the Agents page's total requests and last-used times stay exact. A usage report whose window reaches back past deleted history says so: `gbrain auth clients --usage` names the `--days` that is complete, the advisor skips its "starter op unused for 90 days" half, and `scripts/derive-starter-ops.ts` refuses. Deleted request detail cannot be restored. `gbrain doctor` reports the log's size and suggests turning retention on once it passes about 1M rows or 1 GiB, asking you first. Proposed and first implemented by @lubosxyz (#6770).
-
-### Itemized changes
+Request log retention (#8952):
- `src/core/mcp-request-log-retention.ts` (new): `pruneMcpRequestLog` deletes rows past the cutoff in batches of 2,000 (at most 200 per run, 400,000 rows), each batch one statement that picks the oldest rows in `created_at` order with `FOR UPDATE SKIP LOCKED`, skips `AUDIT_LOG_OPERATIONS`, deletes them and adds them to `mcp_request_log_rollup`, so a failed tally deletes nothing and two prunes at once never double-count. `runMcpLogRetention` reads `cycle.purge.mcp_request_log_retention_days` and records each run under `cycle.purge.mcp_request_log_last_prune`. `startMcpLogPruneTicker` is the hourly PGLite prune with a 3-second budget that yields between batches. `lifetimeUsage` adds kept rows and the tally.
-- Migration v297 adds `mcp_request_log_rollup` (`token_name`, `requests`, `last_used_at`, `pruned_through`) with RLS on. It copies and deletes nothing.
+- `access_admin`, the owner access administration audit row (GST-1094), is in `AUDIT_LOG_OPERATIONS` too, so retention never prunes it and usage reports never count it.
+- Migration v302 adds `mcp_request_log_rollup` (`token_name`, `requests`, `last_used_at`, `pruned_through`) with RLS on. It copies and deletes nothing.
- `src/core/cycle.ts`: the `purge` phase runs the prune when retention is set and reports `purged_mcp_request_log_count` when it removed rows.
- `src/commands/serve.ts`: both `gbrain serve` and `gbrain serve --http` start the hourly prune on PGLite, paused while a delegated sync runs.
- `src/core/mcp-usage.ts`: `readClientOpUsageWithCoverage` returns each window's coverage (`truncated`, `covered_days`, `pruned_before`) and `truncatedWindowNote` the fix and recovery sentence; `AUDIT_LOG_OPERATIONS` names the never-pruned rows. `readClientOpUsage` is unchanged.
@@ -75,6 +60,24 @@ Proposed and first implemented by @Kkkkkuro (#8625).
- Docs: `docs/mcp/ADMIN.md` ("Request log retention"), `docs/operations/mcp-surface-runbook.md`, `docs/architecture/system-of-record.md`.
- Tests: `test/mcp-request-log-retention.test.ts` (PGLite and Postgres, repo-less: off by default, every row class tallied exactly, audit rows kept, capped runs resume, a failed tally deletes nothing, a missing tally table skips, `config set` refusals, the PGLite ticker under a live `serve --http`, two prunes at once on Postgres), `test/serve-http-admin-request-log-retention.test.ts`, `test/doctor-mcp-request-log-retention.test.ts`, `test/mcp-request-log-retention-cli.serial.test.ts` (`auth clients` and `derive-starter-ops` through the real entry points), and new cases in `test/mcp-usage.test.ts` and `test/advisor-mcp-client-fit.test.ts`.
+Remote `think` model (#9050):
+
+- `src/core/ops/takes.ts`: `remoteThinkModel` resolves the requested model, the host think model and each `think.remote_models` entry through the same alias resolution and normalization, then runs the requested model only when it is the host model, or when it is listed, passes `probeChatModel` and has its provider's key. For remote callers, the #1698 explicit-model error no longer applies and `rounds` is 1.
+- `src/core/interop-notices.ts`, `src/core/error-registry.ts`: the `model_override_ignored` info notice (per session for each reason); for `not_allowed` its fix is `gbrain config set think.remote_models <models>` on the brain host (paid consent).
+- `src/commands/think.ts`: the thin client turns the server's `MODEL_OVERRIDE_IGNORED:*` warning into the same notice, and `--model` help says what a thin client gets.
+- `src/core/config-runtime-keys.ts`: `think.remote_models` is a registered key; no remote operation writes config, so only the host sets it.
+- `src/core/behavior-change-notice.ts`: one row for the remote `think` model rule. Docs: `docs/guides/remote-mcp.md` security posture.
+- Tests: `test/think-remote-model.test.ts` (PGLite and Postgres, remote MCP dispatch on a repo-less brain): an unlisted model, a listed model, a listed model the host cannot run, a listed model whose provider key the host lacks, the host model named explicitly, remote `rounds`, the local operation keeping #1698, and a keyless brain with and without `model`; `test/think-remote-model-thin-client.serial.test.ts`: the thin-client `--model` notice; `test/think-pipeline.test.ts` pins the #1698 error on the local caller and no error for a remote one.
+
+A moved brain folder (#8950):
+
+- `src/core/persistence/physical-root-record.ts`: `describeMovedPhysicalRoot` (read-only file evidence: the stamp's recorded root is gone, and the reservation of that root, beside it or beside the new root after a parent rename, carries the stamp's token, brain and worktree; `sameDirectory` from device, inode and birth time), `physicalRootMovedError` (path-free) and `physicalRootMovedRefusal` (the local CLI refusal with an `ask_user` fix chain in argv form, paths shell-quoted in the prose). An ownership stamp other users can read at the new path now refuses `ownership_record_not_private` instead of the generic error.
+- `src/core/persistence/physical-root.ts`: `movedPhysicalRoot` accepts the evidence only for this brain, a worktree this host owns and a host binding still at the recorded root; `reservePhysicalRoot` raises the path-free refusal on its copied-marker branch.
+- `src/core/persistence/source-lifecycle.ts`, `topology-locks.ts`, `administration.ts`: `add`, `claim`, `rebind` and `writer claim` build the full refusal (never for the automatic first-write claim); their dry runs predict it, and a rebind dry run of a missing checkout refuses `source_checkout_missing` like the real run.
+- `src/core/persistence/verb-errors.ts`, `src/core/error-registry.ts`: the `physical_root_moved` reason and its explanation; `docs/guides/error-codes.md` regenerated.
+- Docs: `docs/architecture/topologies.md#moved-root`, `docs/guides/write-refusals.md#moved-root`.
+- Tests: `test/physical-root-moved-8625.test.ts` (PGLite and Postgres: leaf and parent moves, bound and removed sources, Git and plain directories, a copy on a new inode, two sources in one worktree, `writer claim --dry-run`, five lookalikes that keep the generic refusal, a readable stamp, the classic keyless set-path, and a remote `put_page` whose refusal carries no path or worktree id).
+
## [0.60.657.0] - 2026-11-11
**A running `gbrain serve`, worker or autopilot no longer fails writes after another process changes a table's columns (GST-2260).** When `gbrain apply-migrations` or an upgrade in another process added, renamed or dropped a column, every pooled connection that had already prepared a `SELECT *` or `RETURNING *` on that table failed its next run with "cached plan must not change result type". Outside a transaction the driver quietly prepared the statement again, but inside one the error had already aborted the transaction, so the caller saw it. A `put_page` came back `internal_error`, or was accepted and then failed at publication, once for each statement on each pooled connection. Version 0.60.646.0 made the write paths re-run the transaction it aborted. Now the first such error also makes every connection in the process prepare its statements again before its next query, and an OAuth token grant whose client read meets it and a minion job's completion or failure record are re-run too. Pools that do not prepare statements (transaction-mode pooler URLs, `prepare: false`) and PGLite are unchanged.
diff --git a/src/commands/doctor/checks/mcp-request-log.ts b/src/commands/doctor/checks/mcp-request-log.ts
index 185f6975d5..047f06d2af 100644
--- a/src/commands/doctor/checks/mcp-request-log.ts
+++ b/src/commands/doctor/checks/mcp-request-log.ts
@@ -54,7 +54,7 @@ export async function mcpRequestLogRetentionResult(
const enable: Action = {
argv: ['gbrain', 'config', 'set', MCP_LOG_RETENTION_KEY, String(SUGGESTED_DAYS)], consent: ['destructive'], actor: 'agent', ask_user: true,
requires_exclusive: false, docs: DOCS, verify: doctorVerify('mcp_request_log_retention'),
- why: `Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than ${SUGGESTED_DAYS} days. Per-client lifetime totals and the surface/memory-setting audit rows are kept.`,
+ why: `Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than ${SUGGESTED_DAYS} days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept.`,
user_message: `Your MCP request log holds ${rowsText} and nothing prunes it. Turn on ${SUGGESTED_DAYS}-day retention? Request details older than ${SUGGESTED_DAYS} days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.`,
};
if (rows >= warnRows || bytes >= warnBytes) {
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 523aedfdb1..50b63b43af 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -1515,7 +1515,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;
{ since: '0.60.655.0', id: 'memory_propose_held_writes_gst1158', text: 'New attested operation `memory_propose` (add it to `--attest-ops`): QM proposes one timeline entry or link on a shared page for the person it serves, and nothing is written until the brain owner runs `gbrain memory-proposals approve <request_id>` (`list`, `show`, `deny --reason`). `get_write_request` and `cancel_write_request` read and withdraw the proposal; an approved one becomes an ordinary write under the same request id. Held text stays in the `memory_proposals` table, out of git, export, search and recall. Proposals expire after `proposals.ttl_hours` (168), at most 10 wait per person and 50 per credential, and closed ones are deleted after `proposals.retention_days` (30). `gbrain doctor` (`memory_proposals_pending`) and `gbrain status` show the queue.' },
{ since: '0.60.655.0', id: 'member_email_link_gst1158', text: 'A member can carry an operator-declared email: `gbrain access member add <id> --email <addr>` or `gbrain access member set <id> --email <addr>|none`, shown by `member list`, stored lower-case and unique per brain, and cleared when the member is removed. `gbrain access member link --email <addr> --qm <id>` (and `gbrain mcp admin link --email`, `member-add --email`, `member-set` over the owner session) links the one member that declares it, exactly as linking by member id does; an unknown email is `not_found` and creates nothing. No OAuth token, attested call or MCP tool can set an email or make a link.' },
{ since: '0.60.655.0', id: 'qm_admin_http_gst1094', text: 'The brain owner can now manage the attest right, members and canonical-id links over the running server: `gbrain mcp admin attest <client> --attest-actor qm|none [--attest-ops <list>]`, `member-add`, `member-disable`, `member-enable`, `members`, `link <member> --qm <id>`, `unlink --qm <id>` and `links`, backed by `/admin/api/access/attest`, `/admin/api/access/members` and `/admin/api/access/member-links`. These routes take the owner session only (never an OAuth token or an MCP tool), refuse what the local `gbrain auth rescope` and `gbrain access member` commands refuse, preview with `--dry-run` where those do, and log each applied change as `access_admin`. Removing a member stays a brain-host command.' },
- { since: '0.60.626.0', id: 'remote_think_host_model_gbra437', text: 'A remote `think` (MCP, HTTP or a thin client) now runs on the brain host\'s think model (`models.think`, then `models.default`) unless the host lists the requested `model` in the new `think.remote_models` key (comma-separated, empty by default). An unlisted model, or a listed one the host cannot run, no longer fails the call with the explicit-model error: the host model answers, `warnings` carries `MODEL_OVERRIDE_IGNORED:not_allowed` or `:unusable`, and the result carries a `model_override_ignored` notice. Remote `rounds` runs one round. The local CLI `--model` is unchanged, and a keyless brain answers as before.' },
+ { since: 'TBD', id: 'remote_think_host_model_gbra437', text: 'A remote `think` (MCP, HTTP or a thin client) now runs on the brain host\'s think model (`models.think`, then `models.default`) unless the host lists the requested `model` in the new `think.remote_models` key (comma-separated, empty by default). An unlisted model, or a listed one the host cannot run, no longer fails the call with the explicit-model error: the host model answers, `warnings` carries `MODEL_OVERRIDE_IGNORED:not_allowed` or `:unusable`, and the result carries a `model_override_ignored` notice. Remote `rounds` runs one round. The local CLI `--model` is unchanged, and a keyless brain answers as before.' },
{ since: 'TBD', id: 'physical_root_moved_8625', text: 'On a managed brain, a checkout moved to a new path (or whose parent folder was renamed) is now named: `gbrain sources add`, `gbrain sources set-path` and `gbrain sources writer claim` refuse with `recovery_required`, detail `physical_root_moved`, naming the recorded path, the worktree and the commands that bring it back, instead of a generic identity error (add, claim) or detail-less `source_checkout_missing` (set-path). Their `--dry-run` now refuses as the real run does: before, the add, claim and set-path dry runs of a moved checkout, the add and claim dry runs of a folder holding a copied ownership stamp, and the set-path dry run of a missing checkout exited 0. Nothing about ownership changed; the dry runs still write nothing.' },
];
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index a7ba37de0a..f30b576399 100644
--- a/test/fixtures/goldens/cli/tools-json.json
+++ b/test/fixtures/goldens/cli/tools-json.json
@@ -2,8 +2,8 @@
"golden": {
"exitCode": 0,
"stderr": "",
- "stdoutBytes": 287202,
- "stdoutSha256": "3338e684664800c7e540db7987158009b713f1ca2a4f07edd7b2d4a617360a37",
+ "stdoutBytes": 287297,
+ "stdoutSha256": "2a78faf22f01cb128b5e148eded7a95ebc08af4b1008d78da19b8dce84a474c6",
"toolNames": [
"remember",
"entity",
@@ -5305,7 +5305,7 @@
"type": "string"
},
"model": {
- "description": "Model override (alias or full id). Falls through models.think → models.default → GBRAIN_MODEL → opus.",
+ "description": "Model override (alias or full id). Falls through models.think → models.default → GBRAIN_MODEL → opus. Remote callers get the host think model unless the host lists this one in think.remote_models.",
"type": "string"
},
"question": {
diff --git a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
index c79b42abc3..db0fddd4c1 100644
--- a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
@@ -1242,7 +1242,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 177 table(s) the applied migrations create exist.",
+ "message": "All 178 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
@@ -4507,6 +4507,54 @@
"name": "fence_integrity",
"status": "warn"
},
+ {
+ "category": "ops",
+ "details": {
+ "bytes": 32768,
+ "docs": "docs/mcp/ADMIN.md#request-log-retention",
+ "retention_days": null,
+ "rows": 0,
+ "rows_exact": true
+ },
+ "elapsed_ms": "<volatile>",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "config",
+ "set",
+ "cycle.purge.mcp_request_log_retention_days",
+ "90",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain config set cycle.purge.mcp_request_log_retention_days 90 --brain host",
+ "consent": [
+ "destructive"
+ ],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md#request-log-retention",
+ "next": "ask_user",
+ "requires_exclusive": false,
+ "user_message": "Your MCP request log holds 0 row(s) (0.0 MB) and nothing prunes it. Turn on 90-day retention? Request details older than 90 days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.",
+ "verify": {
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "mcp_request_log_retention",
+ "--json",
+ "--brain",
+ "host"
+ ]
+ },
+ "why": "Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than 90 days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept."
+ },
+ "message": "The MCP request log holds 0 row(s) (0.0 MB); request-log retention is off, so it keeps every request.",
+ "name": "mcp_request_log_retention",
+ "readiness_state": "disabled_by_choice",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"elapsed_ms": "<volatile>",
@@ -6383,7 +6431,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 177 table(s) the applied migrations create exist.",
+ "message": "All 178 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
@@ -9660,6 +9708,54 @@
"name": "fence_integrity",
"status": "warn"
},
+ {
+ "category": "ops",
+ "details": {
+ "bytes": 32768,
+ "docs": "docs/mcp/ADMIN.md#request-log-retention",
+ "retention_days": null,
+ "rows": 0,
+ "rows_exact": true
+ },
+ "elapsed_ms": "<volatile>",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "config",
+ "set",
+ "cycle.purge.mcp_request_log_retention_days",
+ "90",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain config set cycle.purge.mcp_request_log_retention_days 90 --brain host",
+ "consent": [
+ "destructive"
+ ],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md#request-log-retention",
+ "next": "ask_user",
+ "requires_exclusive": false,
+ "user_message": "Your MCP request log holds 0 row(s) (0.0 MB) and nothing prunes it. Turn on 90-day retention? Request details older than 90 days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.",
+ "verify": {
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "mcp_request_log_retention",
+ "--json",
+ "--brain",
+ "host"
+ ]
+ },
+ "why": "Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than 90 days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept."
+ },
+ "message": "The MCP request log holds 0 row(s) (0.0 MB); request-log retention is off, so it keeps every request.",
+ "name": "mcp_request_log_retention",
+ "readiness_state": "disabled_by_choice",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"elapsed_ms": "<volatile>",
diff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
index 223b5dcca4..cbbf2fb38c 100644
--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
@@ -1203,7 +1203,7 @@
{
"category": "ops",
"elapsed_ms": "<volatile>",
- "message": "RLS enabled on 176/176 public tables",
+ "message": "RLS enabled on 177/177 public tables",
"name": "rls",
"status": "ok"
},
@@ -1245,7 +1245,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 176 table(s) the applied migrations create exist.",
+ "message": "All 177 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
@@ -4517,6 +4517,54 @@
"name": "fence_integrity",
"status": "warn"
},
+ {
+ "category": "ops",
+ "details": {
+ "bytes": 32768,
+ "docs": "docs/mcp/ADMIN.md#request-log-retention",
+ "retention_days": null,
+ "rows": 0,
+ "rows_exact": false
+ },
+ "elapsed_ms": "<volatile>",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "config",
+ "set",
+ "cycle.purge.mcp_request_log_retention_days",
+ "90",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain config set cycle.purge.mcp_request_log_retention_days 90 --brain host",
+ "consent": [
+ "destructive"
+ ],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md#request-log-retention",
+ "next": "ask_user",
+ "requires_exclusive": false,
+ "user_message": "Your MCP request log holds ~0 row(s) (0.0 MB) and nothing prunes it. Turn on 90-day retention? Request details older than 90 days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.",
+ "verify": {
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "mcp_request_log_retention",
+ "--json",
+ "--brain",
+ "host"
+ ]
+ },
+ "why": "Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than 90 days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept."
+ },
+ "message": "The MCP request log holds ~0 row(s) (0.0 MB); request-log retention is off, so it keeps every request.",
+ "name": "mcp_request_log_retention",
+ "readiness_state": "disabled_by_choice",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"elapsed_ms": "<volatile>",
@@ -6352,7 +6400,7 @@
{
"category": "ops",
"elapsed_ms": "<volatile>",
- "message": "RLS enabled on 176/176 public tables",
+ "message": "RLS enabled on 177/177 public tables",
"name": "rls",
"status": "ok"
},
@@ -6394,7 +6442,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 176 table(s) the applied migrations create exist.",
+ "message": "All 177 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
@@ -9678,6 +9726,54 @@
"name": "fence_integrity",
"status": "warn"
},
+ {
+ "category": "ops",
+ "details": {
+ "bytes": 32768,
+ "docs": "docs/mcp/ADMIN.md#request-log-retention",
+ "retention_days": null,
+ "rows": 0,
+ "rows_exact": false
+ },
+ "elapsed_ms": "<volatile>",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "config",
+ "set",
+ "cycle.purge.mcp_request_log_retention_days",
+ "90",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain config set cycle.purge.mcp_request_log_retention_days 90 --brain host",
+ "consent": [
+ "destructive"
+ ],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md#request-log-retention",
+ "next": "ask_user",
+ "requires_exclusive": false,
+ "user_message": "Your MCP request log holds ~0 row(s) (0.0 MB) and nothing prunes it. Turn on 90-day retention? Request details older than 90 days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.",
+ "verify": {
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "mcp_request_log_retention",
+ "--json",
+ "--brain",
+ "host"
+ ]
+ },
+ "why": "Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than 90 days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept."
+ },
+ "message": "The MCP request log holds ~0 row(s) (0.0 MB); request-log retention is off, so it keeps every request.",
+ "name": "mcp_request_log_retention",
+ "readiness_state": "disabled_by_choice",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"elapsed_ms": "<volatile>",
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index a0315b701f..7f3a459d08 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -1084,7 +1084,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 177 table(s) the applied migrations create exist.",
+ "message": "All 178 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
@@ -3653,6 +3653,54 @@
"name": "fence_integrity",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "bytes": 32768,
+ "docs": "docs/mcp/ADMIN.md#request-log-retention",
+ "retention_days": null,
+ "rows": 0,
+ "rows_exact": true
+ },
+ "elapsed_ms": "<volatile>",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "config",
+ "set",
+ "cycle.purge.mcp_request_log_retention_days",
+ "90",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain config set cycle.purge.mcp_request_log_retention_days 90 --brain host",
+ "consent": [
+ "destructive"
+ ],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md#request-log-retention",
+ "next": "ask_user",
+ "requires_exclusive": false,
+ "user_message": "Your MCP request log holds 0 row(s) (0.0 MB) and nothing prunes it. Turn on 90-day retention? Request details older than 90 days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.",
+ "verify": {
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "mcp_request_log_retention",
+ "--json",
+ "--brain",
+ "host"
+ ]
+ },
+ "why": "Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than 90 days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept."
+ },
+ "message": "The MCP request log holds 0 row(s) (0.0 MB); request-log retention is off, so it keeps every request.",
+ "name": "mcp_request_log_retention",
+ "readiness_state": "disabled_by_choice",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"elapsed_ms": "<volatile>",
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index 783f42dc49..daa7898044 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -1131,7 +1131,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 177 table(s) the applied migrations create exist.",
+ "message": "All 178 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
@@ -3698,6 +3698,54 @@
"name": "fence_integrity",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "bytes": 32768,
+ "docs": "docs/mcp/ADMIN.md#request-log-retention",
+ "retention_days": null,
+ "rows": 0,
+ "rows_exact": true
+ },
+ "elapsed_ms": "<volatile>",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "config",
+ "set",
+ "cycle.purge.mcp_request_log_retention_days",
+ "90",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain config set cycle.purge.mcp_request_log_retention_days 90 --brain host",
+ "consent": [
+ "destructive"
+ ],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md#request-log-retention",
+ "next": "ask_user",
+ "requires_exclusive": false,
+ "user_message": "Your MCP request log holds 0 row(s) (0.0 MB) and nothing prunes it. Turn on 90-day retention? Request details older than 90 days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.",
+ "verify": {
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "mcp_request_log_retention",
+ "--json",
+ "--brain",
+ "host"
+ ]
+ },
+ "why": "Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than 90 days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept."
+ },
+ "message": "The MCP request log holds 0 row(s) (0.0 MB); request-log retention is off, so it keeps every request.",
+ "name": "mcp_request_log_retention",
+ "readiness_state": "disabled_by_choice",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"elapsed_ms": "<volatile>",
diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.json
index 89a661b029..41f5d8dc32 100644
--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json
+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json
@@ -1092,7 +1092,7 @@
{
"category": "ops",
"elapsed_ms": "<volatile>",
- "message": "RLS enabled on 176/176 public tables",
+ "message": "RLS enabled on 177/177 public tables",
"name": "rls",
"status": "ok"
},
@@ -1134,7 +1134,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 176 table(s) the applied migrations create exist.",
+ "message": "All 177 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
@@ -3708,6 +3708,54 @@
"name": "fence_integrity",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "bytes": 32768,
+ "docs": "docs/mcp/ADMIN.md#request-log-retention",
+ "retention_days": null,
+ "rows": 0,
+ "rows_exact": false
+ },
+ "elapsed_ms": "<volatile>",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "config",
+ "set",
+ "cycle.purge.mcp_request_log_retention_days",
+ "90",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain config set cycle.purge.mcp_request_log_retention_days 90 --brain host",
+ "consent": [
+ "destructive"
+ ],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/mcp/ADMIN.md#request-log-retention",
+ "next": "ask_user",
+ "requires_exclusive": false,
+ "user_message": "Your MCP request log holds ~0 row(s) (0.0 MB) and nothing prunes it. Turn on 90-day retention? Request details older than 90 days (operation, status, parameters, errors) will be deleted and cannot be restored; per-client totals and audit rows are kept.",
+ "verify": {
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "mcp_request_log_retention",
+ "--json",
+ "--brain",
+ "host"
+ ]
+ },
+ "why": "Turns on the request-log prune: the next cycle purge phase (or, on a PGLite brain, a live serve within the hour) deletes request rows older than 90 days. Per-client lifetime totals and the audit rows (surface, memory-setting and access changes) are kept."
+ },
+ "message": "The MCP request log holds ~0 row(s) (0.0 MB); request-log retention is off, so it keeps every request.",
+ "name": "mcp_request_log_retention",
+ "readiness_state": "disabled_by_choice",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"elapsed_ms": "<volatile>",
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index 05cb2c3c73..60036ae775 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -1,6 +1,6 @@
{
"golden": {
- "count": 296,
+ "count": 297,
"gaps": [
17,
18,
@@ -97,7 +97,7 @@
"verifyProjectionStatistics": "0d231b04ecfbc5a4109d6fca9567bf4e8c9e9db6c3fbbb35212e026579ed6f67",
"withSchemaLockTimeout": "95605bd3004955e11e936c7a4aa6889319b401098abf9db18ef3e48da2c3fc59"
},
- "latest": 301,
+ "latest": 302,
"records": [
{
"handler": {
@@ -4891,6 +4891,19 @@
"transaction": "absent",
"verify": "absent",
"version": 301
+ },
+ {
+ "handler": "absent",
+ "idempotent": true,
+ "name": "mcp_request_log_rollup",
+ "sql": {
+ "length": 415,
+ "sha256": "fbbd86c93e5131171c0749954ad969cd518b0d08f0acd45743360f2dfd5b1210"
+ },
+ "sqlFor": "absent",
+ "transaction": "absent",
+ "verify": "absent",
+ "version": 302
}
],
"versions": [
@@ -5189,7 +5202,8 @@
298,
299,
300,
- 301
+ 301,
+ 302
]
},
"normalizer": "migrations-record-v1"