Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(minions): stop advertising a nonexistent allow-protected flag (#6196)
garrytanbea141fac4ef
diff --git a/src/core/minions/handlers/unify-types.ts b/src/core/minions/handlers/unify-types.tsindex af99cba45b..e7df9f5154 100644--- a/src/core/minions/handlers/unify-types.ts+++ b/src/core/minions/handlers/unify-types.ts@@ -11,9 +11,9 @@ import { OperationError } from '../../ops/contract.ts';* migration that retypes 25K+ pages, creates alias rows, converts edge-* shaped pages to link rows, AND flips the active pack at end of run.* manual_only via src/core/onboard/render.ts:MANUAL_ONLY_PROTECTED_JOBS.- * Dry-run preview: `gbrain jobs submit unify-types --allow-protected- * --params '{"target_pack":"gbrain-base-v2"}'`; apply with- * '{"target_pack":"gbrain-base-v2","apply":true}'.+ * Dry-run preview: `gbrain jobs submit unify-types --params+ * '{"target_pack":"gbrain-base-v2"}' --follow` (`jobs submit` opts protected+ * names in itself); apply with '{"target_pack":"gbrain-base-v2","apply":true}'.*/export function makeUnifyTypesHandler(engine: BrainEngine): MinionHandler {return async (job) => {diff --git a/test/extract-atoms-drain.test.ts b/test/extract-atoms-drain.test.tsindex 7fae5f209c..1ca442dad5 100644--- a/test/extract-atoms-drain.test.ts+++ b/test/extract-atoms-drain.test.ts@@ -169,7 +169,7 @@ describe('runExtractAtomsDrain (issue #1678)', () => {// #1685 GAP D (CODEX #1) — the auto-drain Minion job burns Haiku, so it must be// PROTECTED: no MCP/OAuth-scoped caller can submit it; only trusted local-// callers (autopilot, explicit CLI with --allow-protected) can.+// callers (autopilot, an explicit `gbrain jobs submit` from the CLI) can.describe('extract-atoms-drain protected-name membership', () => {it('extract-atoms-drain is PROTECTED', () => {expect(isProtectedJobName('extract-atoms-drain')).toBe(true);@@ -208,12 +208,14 @@ describe('shared wiring helper holds the cycle lock (5A)', () => {// The register comment is the only place an operator learns how a PROTECTED// name gets submitted from the CLI. `jobs submit` sets allowProtectedSubmit-// itself for protected names; there is no `--allow-protected` flag, and a+// itself for protected names; there is no allow-protected flag, and a// comment advertising one sends operators to a flag that exits "unknown".+// The repo-wide form of this pin is test/no-allow-protected-flag.test.ts.describe('protected-names register comment names the real trust mechanism', () => {const src = readFileSync(join(import.meta.dir, '../src/core/minions/protected-names.ts'), 'utf8');- it('does not advertise the non-existent --allow-protected flag', () => {- expect(src).not.toContain('--allow-protected');+ const flag = ['--allow', 'protected'].join('-');+ it('does not advertise the non-existent allow-protected flag', () => {+ expect(src).not.toContain(flag);expect(src).toContain('allowProtectedSubmit');});});diff --git a/test/jobs-unify-types-default-dryrun.test.ts b/test/jobs-unify-types-default-dryrun.test.tsindex a05994d513..a41c7c7f3f 100644--- a/test/jobs-unify-types-default-dryrun.test.ts+++ b/test/jobs-unify-types-default-dryrun.test.ts@@ -2,7 +2,7 @@* #1575 — the unify-types WORKER registration defaulted `apply` to true,* while the handler interface documents "Default false (dry-run)". The* canonical operator invocation —- * gbrain jobs submit unify-types --allow-protected --params '{"target_pack":"X"}'+ * gbrain jobs submit unify-types --params '{"target_pack":"X"}'* — therefore applied a one-shot destructive taxonomy migration on first* invocation, with no dry-run checkpoint.*diff --git a/test/no-allow-protected-flag.test.ts b/test/no-allow-protected-flag.test.tsnew file mode 100644index 0000000000..d2009ceb54--- /dev/null+++ b/test/no-allow-protected-flag.test.ts@@ -0,0 +1,31 @@+/**+ * #6196 — there is no allow-protected flag. `gbrain jobs submit` sets the+ * protected-job opt-in itself for protected names, so every comment, skill or+ * migration note that tells an operator to pass the flag sends an agent to a+ * command line that does not mean what it says. One repo-wide guard over+ * src/, skills/ and test/ (CHANGELOG history excluded) keeps it from coming+ * back. The needle is assembled at runtime so this file does not match itself.+ */+import { describe, expect, it } from 'bun:test';+import { readdirSync, readFileSync } from 'node:fs';+import { join, relative } from 'node:path';++const ROOT = join(import.meta.dir, '..');+const FLAG = ['--allow', 'protected'].join('-');+const FLAG_RE = new RegExp(`${FLAG}(?![\\w-])`);++function files(dir: string): string[] {+ return readdirSync(dir, { withFileTypes: true }).flatMap(e => {+ const p = join(dir, e.name);+ if (e.isDirectory()) return e.name === 'node_modules' ? [] : files(p);+ return /\.(ts|tsx|mjs|js|md|json|sh)$/.test(e.name) ? [p] : [];+ });+}++describe(`no ${FLAG} flag references`, () => {+ it('src/, skills/ and test/ never mention the nonexistent flag', () => {+ const hits = ['src', 'skills', 'test'].flatMap(d => files(join(ROOT, d))).flatMap(file =>+ readFileSync(file, 'utf8').split('\n').flatMap((line, i) => (FLAG_RE.test(line) ? [`${relative(ROOT, file)}:${i + 1}`] : [])));+ expect(hits).toEqual([]);+ });+});diff --git a/test/schema-pack-unify-types-handler.test.ts b/test/schema-pack-unify-types-handler.test.tsindex 4eabcab3cc..209fd36002 100644--- a/test/schema-pack-unify-types-handler.test.ts+++ b/test/schema-pack-unify-types-handler.test.ts@@ -230,7 +230,7 @@ describe('#2184 conversation-shaped types survive v2 unify', () => {// #1575 — the jobs worker registration must honor the handler's documented// dry-run default. `apply: data.apply ?? true` made the canonical operator-// invocation (`gbrain jobs submit unify-types --allow-protected --params+// invocation (`gbrain jobs submit unify-types --params// '{"target_pack":...}'`) destructively retype pages by default while// UnifyTypesOpts.apply documents 'Default false (dry-run)'. Structural pin —// the worker source must default apply to false.