Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(docs): widen the doc-drift guard to agent entry points and docs/mcp; fix drift (G6)

garrytan6f14fcbfd5eb
diff --git a/docs/UPGRADING_DOWNSTREAM_AGENTS.md b/docs/UPGRADING_DOWNSTREAM_AGENTS.md
index 638039f9a9..403f085cde 100644
--- a/docs/UPGRADING_DOWNSTREAM_AGENTS.md
+++ b/docs/UPGRADING_DOWNSTREAM_AGENTS.md
@@ -21,8 +21,9 @@ Cross-reference against your fork's local skill files.
## Why this exists
-`gbrain upgrade` ships the new binary. `gbrain post-upgrade [--execute --yes]` runs
-the schema migrations and backfills the data. But the **skill files themselves**
+`gbrain upgrade` ships the new binary and runs `gbrain post-upgrade`, which applies
+the schema migrations and backfills the data (`gbrain apply-migrations --yes` runs
+them by hand). But the **skill files themselves**
that tell the agent how to behave — those are user-owned. If your `~/git/<your-agent>/workspace/skills/brain-ops/SKILL.md`
says `# Based on gbrain v0.10.0` at the top, it doesn't know about v0.12.0 features.
diff --git a/docs/guides/google-connect.md b/docs/guides/google-connect.md
index 4de6c77cbe..e6b508524e 100644
--- a/docs/guides/google-connect.md
+++ b/docs/guides/google-connect.md
@@ -459,6 +459,14 @@ The whole setup is exactly two user interactions: (1) the GCP checklist +
client JSON hand-back, (2) one consent click. Never pass secrets via argv —
use `--client-json <path>`, stdin, or env.
+**Exit codes (contract v1 legacy).** `gbrain google` exits 0 when done, 1 when
+it failed, and 2 both for usage errors and when it is waiting on the user (for
+example `status: "awaiting_consent"` after printing the consent URL, or
+`status: "no_brain"`). Other gbrain commands use exit 3 for "the user must agree
+first"; `google` keeps 2 under contract v1 and moves to 3 in a future contract
+version. Branch on the JSON `status`, not on exit 2 alone. `next_action` is the
+legacy name for `fix` ([legacy advice names](../protocol/AGENT_OPERATOR_v1.md#legacy-advice-names)).
+
## Attachment receipts and historical repair
Gmail attachment receipts record filenames, MIME types, byte sizes when supplied,
diff --git a/docs/guides/remote-mcp.md b/docs/guides/remote-mcp.md
index 6d5fe3b25e..3d246f1b79 100644
--- a/docs/guides/remote-mcp.md
+++ b/docs/guides/remote-mcp.md
@@ -55,7 +55,11 @@ PGLite brain's single-writer lock. Every step is reported as a named check
Exit codes: `0` done, `1` failed, `2` needs confirmation (`--yes`, or you
declined the prompt) or a step is still pending (a tailnet feature to enable,
-Tailscale login, certificate issuance). Which exit 2 it is matters:
+Tailscale login, certificate issuance). Exit 2 for "needs confirmation" is a documented
+contract v1 legacy: every other gbrain command uses exit 3 for
+`confirmation_required` ([exit codes](exit-codes.md)), and `mcp expose` moves to 3
+in a future contract version. Read the JSON `reason` rather than the exit code
+alone. Which exit 2 it is matters:
- A **pre-check** exit 2 — `consent` (`confirmation_required`, `declined`),
`tailscale.login` (`tailscale_daemon_not_running`, `tailscale_login_manual`,
diff --git a/test/doc-claims.test.ts b/test/doc-claims.test.ts
index 8389692b28..b922f29f7c 100644
--- a/test/doc-claims.test.ts
+++ b/test/doc-claims.test.ts
@@ -38,6 +38,8 @@ const RETRACTED: Claim[] = [
{ claim: 'Verify via the `auto_links` field in the put_page response (`{ created', why: '#4679: same retracted inline auto_links promise' },
{ claim: 'No manual `add_link` calls needed for ordinary page writes', why: '#4679: HTTP writers need a host sweep or explicit add_link' },
{ claim: 'nobody else ships together', why: 'exclusivity claim retracted from the primary docs' },
+ { claim: 'post-upgrade [--execute', why: '`gbrain post-upgrade` has no --execute flag; `gbrain upgrade` runs it, `gbrain apply-migrations --yes` runs migrations by hand' },
+ { claim: '`gbrain upgrade` is the whole fix', why: 'an upgrade can need follow-up steps (migrations, repair previews); docs name the verify step instead (agent operator wave G3)' },
{ claim: 'keychain and survives', why: '#4741: the empty-dir hermetic config does not keep the macOS keychain login across logout' },
];
diff --git a/test/docs-cli-commands.test.ts b/test/docs-cli-commands.test.ts
index c586586de3..388b55b29d 100644
--- a/test/docs-cli-commands.test.ts
+++ b/test/docs-cli-commands.test.ts
@@ -8,8 +8,10 @@
* and checks each verb against the live CLI surface: CLI_ONLY, operation
* cliHints names (non-hidden), and aliases.
*
- * Docs-CLI truth check: in docs/guides/, docs/migrations/ and skills/ each
- * invocation's flags must also pass the production argument pipeline
+ * Docs-CLI truth check: in docs/guides/, docs/migrations/, docs/mcp/, skills/
+ * and the root agent entry points (AGENTS.md, INSTALL_FOR_AGENTS.md,
+ * BOOTSTRAP_FOR_AGENTS.md, CLAUDE.md, llms.txt) each invocation's flags must
+ * also pass the production argument pipeline
* (parseGlobalFlags + validateCommandFlags, see test/helpers/
* cli-command-surface.ts), so a documented flag the CLI rejects fails here.
*
@@ -48,8 +50,11 @@ const EXCLUDED = [
'docs/test-audit/',
];
-/** Trees whose invocations are checked for flags as well as verbs. */
-const FLAG_CHECKED = ['docs/guides/', 'docs/migrations/', 'skills/'];
+/** Root files agents read first: scanned for verbs and flags. */
+const AGENT_ENTRY_POINTS = ['AGENTS.md', 'INSTALL_FOR_AGENTS.md', 'BOOTSTRAP_FOR_AGENTS.md', 'CLAUDE.md', 'llms.txt'];
+
+/** Trees and files whose invocations are checked for flags as well as verbs. */
+const FLAG_CHECKED = ['docs/guides/', 'docs/migrations/', 'docs/mcp/', 'skills/', ...AGENT_ENTRY_POINTS];
/**
* Shrink-only: file → the offending verbs/flags it may carry, with why.
@@ -73,7 +78,7 @@ function* mdFiles(dir: string): Generator<string> {
}
function scanText(rel: string, text: string, valid: Set<string>): Violation[] {
- const checkFlags = FLAG_CHECKED.some((t) => rel.startsWith(t));
+ const checkFlags = FLAG_CHECKED.some((t) => (t.endsWith('/') ? rel.startsWith(t) : rel === t));
const out: Violation[] = [];
for (const { code, line, historical } of codeRegions(text)) {
if (historical) continue;
@@ -93,7 +98,10 @@ function scanText(rel: string, text: string, valid: Set<string>): Violation[] {
function scan(): Violation[] {
const valid = liveCliVerbs();
- const files = [join(ROOT, 'README.md'), ...mdFiles(join(ROOT, 'docs')), ...mdFiles(join(ROOT, 'skills'))];
+ const files = [
+ join(ROOT, 'README.md'), ...AGENT_ENTRY_POINTS.map((f) => join(ROOT, f)),
+ ...mdFiles(join(ROOT, 'docs')), ...mdFiles(join(ROOT, 'skills')),
+ ];
const out: Violation[] = [];
for (const file of files) {
const rel = relative(ROOT, file);
@@ -106,6 +114,11 @@ function scan(): Violation[] {
const allowed = (v: Violation) => ALLOWLIST[v.file]?.tokens.includes(v.token) ?? false;
describe('#3502 — docs reference only real gbrain commands and flags', () => {
+ test('the agent entry points are scanned, flags included', () => {
+ for (const f of AGENT_ENTRY_POINTS) expect(FLAG_CHECKED).toContain(f);
+ expect(FLAG_CHECKED).toContain('docs/mcp/');
+ });
+
const violations = scan();
test('every `gbrain <verb> [--flag]` in README/docs/skills resolves against the live CLI', () => {
diff --git a/test/helpers/cli-command-surface.ts b/test/helpers/cli-command-surface.ts
index 1936597b38..8fe3838968 100644
--- a/test/helpers/cli-command-surface.ts
+++ b/test/helpers/cli-command-surface.ts
@@ -90,6 +90,7 @@ export function gbrainInvocations(code: string): Invocation[] {
const verb = m[1]!;
if (!/^[a-z][a-z0-9_-]{2,}$/.test(verb)) continue;
if (!commandPosition(code.slice(0, m.index))) continue;
+ if (verb === 'notice' && code[m.index! - 1] === '[') continue; // `[gbrain notice <code> …]` block prefix, not a command
out.push({ verb, argv: shellWords(code.slice(m.index! + m[0].length - verb.length)) });
}
return out;