Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(mcp): attested-actor check reads normalized arguments, so acting_user "" or null reads as omitted (GST-923)
garrytandb198bd45e91
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9d1ed6647a..fc9b62a80c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,12 +12,13 @@ identifiers and attribution are available in the pre-removal Git revision## [Unreleased]-**GPT models that fill every optional tool argument with `""` or `null` can read pages again in SkillOpt rollouts and `gbrain call`.** GPT-6.1 Sol sends `known_as_of: ""`, `cursor: ""`, `section: ""` and `grep: ""` instead of leaving those arguments out. MCP dispatch and the subagent tool registry already treated `""` on an optional string argument, and `null` on any optional argument, as not provided. The SkillOpt rollout and write-capture registries and `gbrain call` passed the arguments to the handler unchanged. There `known_as_of: ""` sent `get_page` into its recorded-time branch, which refused with "known_as_of must be an ISO 8601 instant", so a SkillOpt probe on GPT-6.1 Sol saw every `get_page` call fail and the model answered from search snippets. The same empty arguments broke about 30 other read operations on those paths (`search`, `get_links`, `traverse_graph`, `recall`, `whois` and more). All three paths now run the same step as MCP dispatch: empty optional arguments are dropped, then the arguments are checked against the operation's schema. A missing required argument or a non-empty invalid value still refuses with `invalid_params`. The SkillOpt registries now also refuse a wrong-typed or out-of-enum argument before the handler runs, with the same `invalid_params` error MCP returns.+**GPT models that fill every optional tool argument with `""` or `null` can read pages again in SkillOpt rollouts and `gbrain call`.** GPT-6.1 Sol sends `known_as_of: ""`, `cursor: ""`, `section: ""` and `grep: ""` instead of leaving those arguments out. MCP dispatch and the subagent tool registry already treated `""` on an optional string argument, and `null` on any optional argument, as not provided. The SkillOpt rollout and write-capture registries and `gbrain call` passed the arguments to the handler unchanged. There `known_as_of: ""` sent `get_page` into its recorded-time branch, which refused with "known_as_of must be an ISO 8601 instant", so a SkillOpt probe on GPT-6.1 Sol saw every `get_page` call fail and the model answered from search snippets. The same empty arguments broke about 30 other read operations on those paths (`search`, `get_links`, `traverse_graph`, `recall`, `whois` and more). All three paths now run the same step as MCP dispatch: empty optional arguments are dropped, then the arguments are checked against the operation's schema. A missing required argument or a non-empty invalid value still refuses with `invalid_params`. The SkillOpt registries now also refuse a wrong-typed or out-of-enum argument before the handler runs, with the same `invalid_params` error MCP returns. Over remote MCP, `memory_recall` with `acting_user: ""` or `acting_user: null` refused with `actor_not_attested`, because the attested-actor check read the arguments before they were normalized. It now reads the normalized arguments, so an empty `acting_user` means the same as leaving it out. A non-empty `acting_user` is still accepted only on an attested call and only when it matches the `x-qm-actor` header.### Itemized changes- `src/core/skillopt/rollout.ts`, `src/core/skillopt/write-capture.ts`: each read tool drops `""` and `null` optional arguments (`normalizeOptionalParams`), then validates (`findInvalidParam`, refusing through `schemaInvalidParams`), before calling the handler. In a rollout, the shared-skill read authorization still runs first.- `src/mcp/server.ts` (`handleToolCall`, behind `gbrain call`): drops empty optional arguments before validation, and the handler receives the cleaned arguments.+- `src/mcp/dispatch.ts` (`dispatchToolCall`): the audience and attested-actor checks on a remote call read the normalized arguments.- `test/tool-args-empty-optional-sol.test.ts`: drives `get_page` with every optional string set to `""`, and again with every optional argument set to `null`, through MCP over HTTP (remote) and stdio (local), `gbrain call`, the subagent registry and both SkillOpt registries. It checks that a missing slug and non-empty bad values still refuse, then sweeps every read operation and checks that empty optional arguments give the same outcome as omitting them. Reverting any one of the three fixes fails it.## [0.60.548.0] - 2026-11-02diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.tsindex 5c665220d7..c1918c969b 100644--- a/src/mcp/dispatch.ts+++ b/src/mcp/dispatch.ts@@ -911,7 +911,9 @@ export async function dispatchToolCall(// GBRA-156: a remote read sees private pages only in the sources its grant names under private_pages: granted_sources.// Writes, local callers and every path outside this call keep the empty set, so they hide or see exactly what they did.// context_pack and delta stay world-only for every caller unless a trusted local one passes include_private, so no grant widens them.- const readOnly = operations.find(o => o.name === name)?.mutating === false;+ const op = operations.find(o => o.name === name);+ const readOnly = op?.mutating === false;+ const args = op && params ? normalizeOptionalParams(op, params) : params;const privateSources = readOnly && opts.remote !== false && !WORLD_ONLY_PACK_OPS.has(name) ? opts.auth?.privatePages?.sources : undefined;const resolved = opts.metaHook && (opts.hotMemoryOff === true || hotMemoryOffIn(params)) ? { ...opts, metaHook: undefined } : opts;// GBRA-218: a remote call also carries its credential's member identity, which every caller-aware read checks page readers against.@@ -923,15 +925,15 @@ export async function dispatchToolCall(let attested: Awaited<ReturnType<typeof resolveAttestedActor>> = null;let access: Awaited<ReturnType<typeof remoteCallerAccess>>;const header = opts.actor?.header ?? undefined;- const actorNamed = header !== undefined || opts.actor?.audience != null || (!!params && Object.prototype.hasOwnProperty.call(params, ACTOR_ARGUMENT));+ const actorNamed = header !== undefined || opts.actor?.audience != null || (!!args && Object.prototype.hasOwnProperty.call(args, ACTOR_ARGUMENT));const assertion = (outcome: AudienceAuditEvent['outcome'], reason?: string) => logAudienceAssertion({ outcome, op: name,audience: [...(attested?.access.audience ?? audience ?? [])], transport: opts.transport ?? 'unknown',principal: opts.auth?.principal ? `${opts.auth.principal.kind}:${opts.auth.principal.id}` : opts.transport === 'stdio' ? 'local_stdio' : 'unknown',...(actorNamed ? { actor: { system: 'qm', ...(header && EXTERNAL_ID_RE.test(header) ? { external_id: header } : {}), ...(reason ? { reason } : {}) } } : {}) });try {- if (audienceInArguments(params)) throw audienceInArgumentsError();+ if (audienceInArguments(args)) throw audienceInArgumentsError();audience = parseAudience(opts.onBehalfOf);- attested = await resolveAttestedActor(engine, { channels: opts.actor, params, op: name, opShape: operations.find(o => o.name === name),+ attested = await resolveAttestedActor(engine, { channels: opts.actor, params: args, op: name, opShape: op,auth: opts.auth, transport: opts.transport, audienceAsserted: audience !== null });access = attested ? attested.access : await remoteCallerAccess(engine, opts.auth, privateSources, opts.transport, audience);} catch (e) {@@ -942,10 +944,10 @@ export async function dispatchToolCall(return withStructuredError(errorResult(e, opts, { op: name }));}assertion(e.code as AudienceAuditEvent['outcome'], e.reason);- return qmMemoryToolResult(name, actorNamed ? actorRefusal(e, opts, name, header, params) : errorResult(e, opts, { op: name }));+ return qmMemoryToolResult(name, actorNamed ? actorRefusal(e, opts, name, header, args) : errorResult(e, opts, { op: name }));}if (audience || attested) assertion('accepted');- const callParams = attested ? attested.params : params;+ const callParams = attested ? attested.params : args;return withCallerAccess(access, async () => {const out = await withRequestIdentityMemo(() => dispatchResolvedCall(engine, name, callParams, resolved));// _meta.access (MCP_META_CHANNELS.md): the view this call was answered under, for the harness; own producer, isolated.