Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Let a brain owner turn off every write under enforced member mode

garrytan4fc6e2fd90f5
diff --git a/docs/guides/enforced-member.md b/docs/guides/enforced-member.md
index e8d7fae916..6510af036d 100644
--- a/docs/guides/enforced-member.md
+++ b/docs/guides/enforced-member.md
@@ -58,6 +58,42 @@ one. `git commit-push` refuses a named
file the member can't read, an access policy file (`.gbrain/`) and any label
change against HEAD; `--pending`, `--push-only` and `--resolve` are refused.
+<a id="writes-off"></a>
+## Turn member writes off
+
+A brain owner who wants member CLIs to read and never write sets one key in the
+brain's config, from a direct session (one without `GBRAIN_ENFORCED_MEMBER`):
+
+```
+gbrain config set access.enforced_member_writes refuse
+```
+
+Then every write under the mode refuses: `put` (a new slug, a page the member
+reads and a page it can't read alike), `link`, `unlink`, `tag`, `untag`,
+`timeline-add`, `remember`, and `edit_page` and `append_page`. The refusal
+comes before any page or source lookup, so it reads the same for every target
+and names none:
+
+```
+gbrain: refused under GBRAIN_ENFORCED_MEMBER=alice-example: writes are off for members on this brain; nothing was saved [GBRAIN_ENFORCED_REFUSED]
+Why: This brain refuses every write under this mode: its config access.enforced_member_writes is not checked, or could not be read.
+Fix: ask the brain owner to save it in a direct session (one without GBRAIN_ENFORCED_MEMBER).
+Recovery: nothing was saved; the same call refuses every time, so do not retry here.
+Docs: docs/guides/enforced-member.md#refused
+```
+
+- The key lives in the brain's database, so it works on a brain with no
+ repository and no environment variable overrides it. `config` is refused
+ under the mode, so a member can't change it.
+- `checked`, or no value, is the default: writes are checked as described
+ above. Any other value, or a config read that fails, refuses (fail closed).
+ `gbrain config set access.enforced_member_writes checked` turns writes back on.
+- Reads are never affected, and neither is a CLI without
+ `GBRAIN_ENFORCED_MEMBER`.
+- `git commit-push` (named paths, `--pull`, `--dry-run`), `sync`,
+ `sources refresh` and `write-request` keep their behaviour under the
+ switch.
+
<a id="refused"></a>
## Refused
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.md
index 58d57d19e9..84fbc44a9f 100644
--- a/docs/guides/error-codes.md
+++ b/docs/guides/error-codes.md
@@ -1658,9 +1658,9 @@ More: [docs/guides/troubleshooting.md#embedding-state](../../docs/guides/trouble
| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
|---|---|---|---|---|---|---|
-| The CLI runs under GBRAIN_ENFORCED_MEMBER and refused the command before it read or changed anything: the command or its arguments are not on the enforced member allow-list, the variable names no usable member, a target page or source is outside what the member reads, or the write would change an access or privacy label. | A launcher pins GBRAIN_ENFORCED_MEMBER so a shared agent turn acts as one member: reads show only what that member reads, writes never touch a page it cannot read or change a label, and anything not classified is refused rather than run as the trusted owner. Stderr starts with gbrain: refused under GBRAIN_ENFORCED_MEMBER=<member>: <command> [GBRAIN_ENFORCED_REFUSED]. | Do not retry here; nothing was changed. Ask the brain owner to run the command in a direct session, one without GBRAIN_ENFORCED_MEMBER. | user | `repeat the read that failed` | 3 | no |
+| The CLI runs under GBRAIN_ENFORCED_MEMBER and refused the command before it read or changed anything: the command or its arguments are not on the enforced member allow-list, the variable names no usable member, a target page or source is outside what the member reads, the write would change an access or privacy label, or the brain turned member writes off (access.enforced_member_writes). | A launcher pins GBRAIN_ENFORCED_MEMBER so a shared agent turn acts as one member: reads show only what that member reads, writes never touch a page it cannot read or change a label, and anything not classified is refused rather than run as the trusted owner. Stderr starts with gbrain: refused under GBRAIN_ENFORCED_MEMBER=<member>: <command> [GBRAIN_ENFORCED_REFUSED]. | Do not retry here; nothing was changed. Ask the brain owner to run the command in a direct session, one without GBRAIN_ENFORCED_MEMBER. | user | `repeat the read that failed` | 3 | no |
-Reasons: `command_not_allowed`, `member_not_usable`, `target_not_readable`, `label_change`, `thin_client`, `as_flag`, `arguments_not_allowed`, `remember_needs_entity`.
+Reasons: `command_not_allowed`, `member_not_usable`, `target_not_readable`, `label_change`, `thin_client`, `as_flag`, `arguments_not_allowed`, `remember_needs_entity`, `writes_off`.
More: [docs/guides/enforced-member.md#refused](../../docs/guides/enforced-member.md#refused)
diff --git a/src/cli/enforced-member.ts b/src/cli/enforced-member.ts
index 0fe0650fa6..7efca4dd4d 100644
--- a/src/cli/enforced-member.ts
+++ b/src/cli/enforced-member.ts
@@ -12,14 +12,14 @@ import type { CallerAccess } from '../core/search/private-visibility.ts';
import { ACCESS_ID_RE } from '../core/access/principals.ts';
import { opError } from '../core/ops/contract.ts';
import { writeCliError } from './cli-error.ts';
-import { CLI_COMMAND_CLASSES, OPERATION_SUBCOMMANDS, enforcedClassOf, type EnforcedClass } from './enforced-member-classes.ts';
+import { CLI_COMMAND_CLASSES, OPERATION_CLASSES, OPERATION_SUBCOMMANDS, enforcedClassOf, type EnforcedClass } from './enforced-member-classes.ts';
export const ENFORCED_MEMBER_ENV = 'GBRAIN_ENFORCED_MEMBER';
export const ENFORCED_REFUSED_TAG = 'GBRAIN_ENFORCED_REFUSED';
export const ENFORCED_DOCS = 'docs/guides/enforced-member.md#refused';
export type EnforcedReason = 'command_not_allowed' | 'member_not_usable' | 'target_not_readable' | 'label_change' | 'thin_client'
- | 'as_flag' | 'arguments_not_allowed' | 'remember_needs_entity';
+ | 'as_flag' | 'arguments_not_allowed' | 'remember_needs_entity' | 'writes_off';
const REASON_TEXT: Record<EnforcedReason, string> = {
command_not_allowed: 'This command is not on the enforced member allow-list.',
@@ -30,6 +30,7 @@ const REASON_TEXT: Record<EnforcedReason, string> = {
as_flag: '--as is refused under this mode.',
arguments_not_allowed: 'These arguments are not allowed under this mode.',
remember_needs_entity: 'remember needs --entity naming the exact slug of a page this member reads.',
+ writes_off: 'This brain refuses every write under this mode: its config access.enforced_member_writes is not checked, or could not be read.',
};
/** The mode's member value, or undefined when the mode is off (the variable unset). */
@@ -67,10 +68,12 @@ export function emitFilteredNotice(): void {
/** A refusal whose first line says what to do instead of naming the command (the prefix and tag stay the same). */
const REASON_HEADLINE: Partial<Record<EnforcedReason, string>> = {
remember_needs_entity: 'remember saves a fact only with --entity <slug of a page you can read>; nothing was saved',
+ writes_off: 'writes are off for members on this brain; nothing was saved',
};
const REASON_NEXT: Partial<Record<EnforcedReason, { fix: string; recovery: string }>> = {
remember_needs_entity: { fix: 'run the Retry command with --entity set to the exact slug of a page you can read.', recovery: 'nothing was saved, so retrying with --entity is safe.' },
+ writes_off: { fix: 'ask the brain owner to save it in a direct session (one without ' + ENFORCED_MEMBER_ENV + ').', recovery: 'nothing was saved; the same call refuses every time, so do not retry here.' },
};
const OWNER_FIX = 'ask the brain owner to run this in a direct session (one without ' + ENFORCED_MEMBER_ENV + ').';
@@ -203,11 +206,27 @@ function namedSources(op: { params: Record<string, unknown> }, params: Record<st
return out;
}
+export const ENFORCED_MEMBER_WRITES_KEY = 'access.enforced_member_writes';
+
+/**
+ * The brain's switch for writes under the mode, read from the database config (never the environment): unset or checked
+ * keeps writes checked; refuse, any other value and a failed read refuse them.
+ */
+export async function enforcedWritesRefused(engine: BrainEngine): Promise<boolean> {
+ try {
+ const value = await engine.getConfig(ENFORCED_MEMBER_WRITES_KEY);
+ return value !== null && value.trim().toLowerCase() !== 'checked';
+ } catch { return true; }
+}
+
/**
- * An operation's argument checks before its context is built: the member resolves, every source it names is one the
- * member reads (the federated __all__ stays: the read scope already drops hidden sources), and get_stats only with --by.
+ * An operation's argument checks before its context is built: a write refuses first when the brain turned member writes
+ * off (before any member, page or source lookup, so every target answers alike; get_write_request only reads a receipt),
+ * then the member resolves, every source it names is one the member reads (the federated __all__ stays: the read scope
+ * already drops hidden sources), and get_stats only with --by.
*/
export async function checkEnforcedOpArgs(engine: BrainEngine, command: string, op: { name: string; params: Record<string, unknown> }, params: Record<string, unknown>): Promise<void> {
+ if (OPERATION_CLASSES[op.name] === 'write' && op.name !== 'get_write_request' && await enforcedWritesRefused(engine)) await refuseEnforced(command, 'writes_off', { engine });
await enforcedAccess(engine, command);
for (const s of namedSources(op, params)) if (s !== '__all__') await checkEnforcedSource(engine, command, s);
if (op.name === 'get_stats' && params.by === undefined) await refuseEnforced(command, 'arguments_not_allowed', { engine });
diff --git a/src/core/config-runtime-keys.ts b/src/core/config-runtime-keys.ts
index 99cf1a4eed..ad69a50d12 100644
--- a/src/core/config-runtime-keys.ts
+++ b/src/core/config-runtime-keys.ts
@@ -30,6 +30,7 @@ export const RUNTIME_READER_CONFIG_KEYS: readonly string[] = [
'access.owner_reads_restricted', // access/owner.ts (GST-2490): '1' lets owner-bound credentials read past readers lists and rules (gbrain access owner reads-restricted on)
'access.members_read_lineage', // access/lineage.ts (GBRA-108 design 3): '1' lets a member read derived pages and facts of origins it reads (gbrain access members-read-lineage on)
'access.serves', // access/serves.ts (GST-363): one or several; explicit wins over the enabled-member count (gbrain setup --serves several writes it)
+ 'access.enforced_member_writes', // cli/enforced-member.ts (GST-2675): refuse makes GBRAIN_ENFORCED_MEMBER refuse every member write; unset or checked = writes checked as today; any other value or a failed read refuses
'access.requester_scope_enforce', // access/requester-scope.ts (GST-363): false turns the unscoped-read refusal on a brain that serves several people into a notice (hosted, until connections are bound); default on
'mcp.stdio_may_act_for', // access/audience.ts (GBRA-231): whom a local stdio server may act for (_meta.on_behalf_of); unset, stdio refuses every audience
'proposals.ttl_hours', 'proposals.max_pending_per_actor', 'proposals.max_pending_per_credential', // persistence/memory-proposals.ts: held QM proposal TTL (168 h) and pending caps (10 per person, 50 per credential)
diff --git a/src/core/error-registry.ts b/src/core/error-registry.ts
index 4f000150ed..9b7c10fcc1 100644
--- a/src/core/error-registry.ts
+++ b/src/core/error-registry.ts
@@ -330,7 +330,7 @@ export const CODES = {
embedding_unconfigured: { class: 'host_only', summary: "The selected brain has no verifiable text embedding model and dimensions." },
embedding_width_mismatch: { class: 'caller', summary: "The embedding model cannot produce the width of the brain's vector column; nothing was changed." },
embedded_core_required: { class: 'caller', summary: "openEngine (gbrain/engine-open) was called without embedded_core: true, so no engine was opened.", why: 'Opening an engine from settings alone is an experimental embedding surface that is off by default; a host opts in explicitly so no existing caller changes behavior.', docs: 'docs/ENGINES.md#opening-an-engine-from-settings-experimental', suggestion: 'Pass embedded_core: true in the settings; the CLI, gbrain serve and mounts open brains through their own connect path and need nothing.' },
- enforced_member_refused: { class: 'consent', exit: 3, actor: 'user', reasons: ['command_not_allowed', 'member_not_usable', 'target_not_readable', 'label_change', 'thin_client', 'as_flag', 'arguments_not_allowed', 'remember_needs_entity'], summary: "The CLI runs under GBRAIN_ENFORCED_MEMBER and refused the command before it read or changed anything: the command or its arguments are not on the enforced member allow-list, the variable names no usable member, a target page or source is outside what the member reads, or the write would change an access or privacy label.", why: 'A launcher pins GBRAIN_ENFORCED_MEMBER so a shared agent turn acts as one member: reads show only what that member reads, writes never touch a page it cannot read or change a label, and anything not classified is refused rather than run as the trusted owner. Stderr starts with gbrain: refused under GBRAIN_ENFORCED_MEMBER=<member>: <command> [GBRAIN_ENFORCED_REFUSED].', docs: 'docs/guides/enforced-member.md#refused', suggestion: 'Do not retry here; nothing was changed. Ask the brain owner to run the command in a direct session, one without GBRAIN_ENFORCED_MEMBER.' },
+ enforced_member_refused: { class: 'consent', exit: 3, actor: 'user', reasons: ['command_not_allowed', 'member_not_usable', 'target_not_readable', 'label_change', 'thin_client', 'as_flag', 'arguments_not_allowed', 'remember_needs_entity', 'writes_off'], summary: "The CLI runs under GBRAIN_ENFORCED_MEMBER and refused the command before it read or changed anything: the command or its arguments are not on the enforced member allow-list, the variable names no usable member, a target page or source is outside what the member reads, the write would change an access or privacy label, or the brain turned member writes off (access.enforced_member_writes).", why: 'A launcher pins GBRAIN_ENFORCED_MEMBER so a shared agent turn acts as one member: reads show only what that member reads, writes never touch a page it cannot read or change a label, and anything not classified is refused rather than run as the trusted owner. Stderr starts with gbrain: refused under GBRAIN_ENFORCED_MEMBER=<member>: <command> [GBRAIN_ENFORCED_REFUSED].', docs: 'docs/guides/enforced-member.md#refused', suggestion: 'Do not retry here; nothing was changed. Ask the brain owner to run the command in a direct session, one without GBRAIN_ENFORCED_MEMBER.' },
engine_embedding_mismatch: { class: 'host_only', actor: 'user', summary: "An engine opened from settings names an embedding model or width that differs from the one its database already records, so initSchema changed nothing.", why: 'The vector column has one width and the brain one embedding model; seeding another over it would make every stored and future embedding unreadable. Changing it is an explicit re-embed the user decides on.', docs: 'docs/ENGINES.md#opening-an-engine-from-settings-experimental', suggestion: "Pass the database's recorded model and width in settings.embedding, or read the recorded identity with gbrain migrate embeddings --status on the brain host and preview a migration from there.", fix: { argv: ['gbrain', 'migrate', 'embeddings', '--status', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: "Read-only: reports the brain's recorded embedding model and width and what a migration would change." } },
embedded_engine_required: { class: 'caller', summary: "An operation that serves an embedding host (file_register, file_verify) was called on an engine the CLI or a server opened, so it did nothing.", why: 'These operations trust a host that stores bytes itself; a brain opened the usual way stores files through file_upload, so the operations stay off there and its behavior is unchanged.', docs: 'docs/ENGINES.md#opening-an-engine-from-settings-experimental', suggestion: 'Call it on an engine opened from settings with settings.storage; a brain the CLI or a server opens stores files only through file_upload (gbrain files upload).' },
engine_closed: { class: 'caller', summary: 'An engine opened from settings was disconnected, which closes it for good, so connect() and reconnect() refuse and nothing was reopened.', docs: 'docs/ENGINES.md#opening-an-engine-from-settings-experimental', suggestion: 'Call openEngine again with the settings to open a new engine.' },
diff --git a/test/enforced-member-writes-off.test.ts b/test/enforced-member-writes-off.test.ts
new file mode 100644
index 0000000000..97100f10d8
--- /dev/null
+++ b/test/enforced-member-writes-off.test.ts
@@ -0,0 +1,34 @@
+/**
+ * GST-2675: the brain setting access.enforced_member_writes, read by enforcedWritesRefused (src/cli/enforced-member.ts).
+ *
+ * 1. Protects: under enforced member mode a write refuses unless the brain's config says checked (or holds no value),
+ * and a config read that fails refuses too.
+ * 2. Fails when: a failed config read, an unknown value or refuse lets a member write through.
+ * 3. Existing coverage: test/enforced-member.serial.test.ts (every write as a real subprocess with the key set).
+ * 4. Real seams: the engine's getConfig, faked here so the read can fail.
+ */
+import { describe, expect, test } from 'bun:test';
+import type { BrainEngine } from '../src/core/engine.ts';
+import { ENFORCED_MEMBER_WRITES_KEY, enforcedWritesRefused } from '../src/cli/enforced-member.ts';
+
+const engineWith = (getConfig: (key: string) => Promise<string | null>) => ({ getConfig }) as unknown as BrainEngine;
+
+describe('enforcedWritesRefused', () => {
+ test('reads access.enforced_member_writes from the brain config', async () => {
+ const seen: string[] = [];
+ await enforcedWritesRefused(engineWith(async key => { seen.push(key); return null; }));
+ expect({ key: ENFORCED_MEMBER_WRITES_KEY, seen }).toEqual({ key: 'access.enforced_member_writes', seen: ['access.enforced_member_writes'] });
+ });
+
+ test('unset and checked allow checked writes; refuse, any other value and a failed read refuse', async () => {
+ const cases: Array<[string, () => Promise<string | null>, boolean]> = [
+ ['unset', async () => null, false],
+ ['checked', async () => 'checked', false],
+ ['refuse', async () => 'refuse', true],
+ ['unknown value', async () => 'chekced', true],
+ ['empty value', async () => '', true],
+ ['read fails', async () => { throw new Error('connection lost'); }, true],
+ ];
+ for (const [name, read, refused] of cases) expect({ name, refused: await enforcedWritesRefused(engineWith(read)) }).toEqual({ name, refused });
+ });
+});
diff --git a/test/enforced-member.serial.test.ts b/test/enforced-member.serial.test.ts
index b2138c084a..9218e5d88b 100644
--- a/test/enforced-member.serial.test.ts
+++ b/test/enforced-member.serial.test.ts
@@ -39,6 +39,7 @@ const OWNER = 'owner-example';
const FIRST = (who: string, command: string) => 'gbrain: refused under GBRAIN_ENFORCED_MEMBER=' + who + ': ' + command + ' [GBRAIN_ENFORCED_REFUSED]';
const NOTICE = 'gbrain: results limited to what GBRAIN_ENFORCED_MEMBER=' + MEMBER + ' may read';
const REMEMBER_FIRST = 'gbrain: refused under GBRAIN_ENFORCED_MEMBER=' + MEMBER + ': remember saves a fact only with --entity <slug of a page you can read>; nothing was saved [GBRAIN_ENFORCED_REFUSED]';
+const WRITES_OFF_FIRST = 'gbrain: refused under GBRAIN_ENFORCED_MEMBER=' + MEMBER + ': writes are off for members on this brain; nothing was saved [GBRAIN_ENFORCED_REFUSED]';
const REMEMBER_RETRY = 'Retry: gbrain remember "<one fact>" --entity <exact slug of a page you can read, from gbrain find or gbrain search> --provenance "<where you learned it>"';
const PAGES = {
@@ -487,6 +488,83 @@ for (const kind of testBackends()) {
.toEqual({ exit: 0, open: true, count: true, leaks: [] });
}, 300_000);
+ test('access.enforced_member_writes refuse: every member write refuses before any lookup, reads and the trusted CLI are unchanged', async () => {
+ const KEY = 'access.enforced_member_writes';
+ const setKey = async (value: string) => {
+ const r = await cli(['config', 'set', KEY, value], { member: null });
+ expect({ value, exit: r.exitCode, err: r.exitCode === 0 ? '' : r.stderr }).toEqual({ value, exit: 0, err: '' });
+ };
+ const page = (title: string, fm = '') => '---\ntype: note\ntitle: ' + JSON.stringify(title) + '\n' + fm + '---\n# ' + title + '\n\nHarbor ledger planning notes for the roadmap.\n';
+ const writes: Array<[string[], string | undefined]> = [
+ [['put', 'notes/writes-off-new-example'], page('Writes off new')],
+ [['put', PAGES.open.slug], page(PAGES.open.title)],
+ [['put', PAGES.other.slug], page(PAGES.other.title, 'readable_by: ["bob-example"]\n')],
+ [['link', PAGES.open.slug, PAGES.team.slug], undefined],
+ [['unlink', PAGES.open.slug, PAGES.other.slug], undefined],
+ [['tag', PAGES.open.slug, 'writes-off-tag'], undefined],
+ [['untag', PAGES.open.slug, 'writes-off-tag'], undefined],
+ [['timeline-add', PAGES.open.slug, '2026-02-01', 'Writes off event'], undefined],
+ [['remember', 'Writes off fact canaryemwritesoff', '--entity', PAGES.open.slug, '--provenance', 'test turn'], undefined],
+ ];
+ const counts = () => withBrain(async engine => {
+ const out: Record<string, number> = {};
+ for (const table of ['pages', 'links', 'tags', 'timeline_entries', 'facts']) out[table] = (await engine.executeRaw<{ n: number }>('SELECT count(*)::int AS n FROM ' + table))[0]!.n;
+ out.content = (await engine.executeRaw<{ n: number }>("SELECT count(*)::int AS n FROM pages WHERE compiled_truth LIKE '%' || $1 || '%'", [PAGES.open.canary]))[0]!.n;
+ return out;
+ });
+ const reads: string[][] = [['list', '--json'], ['get', PAGES.open.slug], ['search', 'harbor ledger', '--json'], ['recall', PAGES.open.slug, '--json'], ['stats', '--by', 'type', '--json']];
+ const readAll = async () => {
+ const out: Array<{ args: string; exit: number; out: string; notice: boolean }> = [];
+ for (const args of reads) { const r = await cli(args); out.push({ args: args.join(' '), exit: r.exitCode, out: r.stdout, notice: r.stderr.includes(NOTICE) }); }
+ return out;
+ };
+ const checkedReads = await readAll();
+ const before = await counts();
+ try {
+ await setKey('refuse');
+ expect(await readAll()).toEqual(checkedReads);
+ const texts = new Set<string>();
+ for (const [args, stdin] of writes) {
+ const r = await cli(args, { stdin });
+ const first = r.stderr.split('\n')[0];
+ expect({ args: args.join(' '), exit: r.exitCode, first, out: r.stdout, leaks: leaks(r.stdout + r.stderr) })
+ .toEqual({ args: args.join(' '), exit: 3, first: WRITES_OFF_FIRST, out: '', leaks: [] });
+ texts.add(r.stderr);
+ }
+ expect(texts.size).toBe(1);
+ const [text] = [...texts];
+ expect(text).toContain('Recovery: nothing was saved');
+ expect(text).toContain('brain owner');
+ for (const slug of ['notes/writes-off-new-example', PAGES.open.slug, PAGES.other.slug, 'notes', 'harbor']) expect({ slug, named: text!.includes(slug) }).toEqual({ slug, named: false });
+ const json = await cli(['put', 'notes/writes-off-new-example', '--json'], { stdin: page('Writes off new') });
+ expect({ exit: json.exitCode, envelope: json.stdout.includes('enforced_member_refused'), reason: /"reason":\s*"writes_off"/.test(json.stdout) })
+ .toEqual({ exit: 3, envelope: true, reason: true });
+ const receipt = await cli(['write-request', crypto.randomUUID()]);
+ expect(receipt.stderr).not.toContain(WRITES_OFF_FIRST);
+ expect(await counts()).toEqual(before);
+ for (const value of ['chekced', 'REFUSE ']) {
+ await setKey(value);
+ const r = await cli(['tag', PAGES.open.slug, 'writes-off-tag']);
+ expect({ value, exit: r.exitCode, first: r.stderr.split('\n')[0] }).toEqual({ value, exit: 3, first: WRITES_OFF_FIRST });
+ }
+ expect(await counts()).toEqual(before);
+ await setKey('refuse');
+ for (const [args, stdin] of writes.filter(([a]) => a[0] !== 'put' || a[1] === 'notes/writes-off-new-example')) {
+ const r = await cli(args, { member: null, stdin });
+ expect({ args: args.join(' '), exit: r.exitCode, err: r.exitCode === 0 ? '' : r.stderr }).toEqual({ args: args.join(' '), exit: 0, err: '' });
+ }
+ const after = await counts();
+ expect({ pages: after.pages, facts: after.facts, timeline: after.timeline_entries }).toEqual({ pages: before.pages + 1, facts: before.facts + 1, timeline: before.timeline_entries + 1 });
+ await setKey('checked');
+ const allowed = await cli(['tag', PAGES.open.slug, 'writes-checked-tag']);
+ expect({ exit: allowed.exitCode, err: allowed.exitCode === 0 ? '' : allowed.stderr }).toEqual({ exit: 0, err: '' });
+ const hidden = await cli(['put', PAGES.other.slug], { stdin: page('Overwrite') });
+ expect({ exit: hidden.exitCode, first: hidden.stderr.split('\n')[0] }).toEqual({ exit: 3, first: FIRST(MEMBER, 'put') });
+ } finally {
+ await withBrain(engine => engine.executeRaw('DELETE FROM config WHERE key = $1', [KEY]));
+ }
+ }, 900_000);
+
test('variable unset: output is unchanged', async () => {
for (const args of [['list', '--json'], ['get', PAGES.other.slug], ['stats', '--json']]) {
const a = await cli(args, { member: null });