Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(search): treat source_ids [] or a blank string as absent (#5390)

garrytan8e2770d72d29
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3135e19a75..7219d4b825 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,7 +20,7 @@ identifiers and attribution are available in the pre-removal Git revision
|---|---|---|
| An agent acting for one member of a shared brain searches | every source the token can read came back; only one `source_id` (or all) could be named | `source_ids: ["source-a", "source-c"]` (CLI `--source-ids source-a,source-c`) reads only those sources, in every arm: keyword, vector, title, other names, entity anchoring, saved facts, the CRAG re-run, think escalation and evidence delivery |
| A remote agent lists a source outside its grant | not possible | `permission_denied` for the whole request, as for `source_id`; a removed or archived source is `unknown_source` |
-| `source_ids` with `source_id`, or an empty list | not possible | the request reads the sources in both; when none remain, nothing is searched and an `empty_retrieval` notice says why (never a fallback to the wider scope) |
+| `source_ids` with `source_id` | not possible | the request reads the sources in both; when none remain, nothing is searched and an `empty_retrieval` notice says why (never a fallback to the wider scope). An empty list or blank string is the same as omitting `source_ids` |
### What to watch for after you upgrade
diff --git a/docs/architecture/key-files/core-services-2.md b/docs/architecture/key-files/core-services-2.md
index 162e66d804..1462769655 100644
--- a/docs/architecture/key-files/core-services-2.md
+++ b/docs/architecture/key-files/core-services-2.md
@@ -50,8 +50,8 @@ Fact and page purge modules (`src/core/facts/purge*.ts`, `deletion-inventory.ts`
- `src/core/ops/raw-data.ts` — `put_raw_data` / `get_raw_data`. `get_raw_data` follows the page soft-delete (a tombstoned page reads as `[]`, `restore_page` brings the rows back; there is no remote `include_deleted` param — `get_page include_deleted: true` verifies the tombstone) and, per #4352, a `visibility: private` page's raw data reads exactly like a missing page's for untrusted callers. Scope comes from `readPolicyOpts(ctx)`, never from MCP parameters.
-- `src/core/ops/search.ts` — the search-domain op module (`search`, `query`, `search_stats`, `search_modes`, `search_tune`, `cache_stats`). Both resolve their source scope through `ops/search-source-scope.ts` and return no rows when it is empty. `query` is the hybrid entry (`hybridSearchCached`) plus two non-hybrid legs that share ONE effective-row-contract helper, `resolveEffectiveLimit(ctx, p)`: an explicit `limit` wins, otherwise the mode-derived `searchLimit` resolved through the same trust-gated chain `hybridSearch` uses (`resolvePerCallMode` ignores a remote caller's `mode`, so a remote client cannot select the tokenmax row count); the config reads run lazily on those paths only. The legs: the image-similarity branch (`embedding_image` vector search, `test/query-image-mode-limit.serial.test.ts`) and the CRAG escalation slice — when `search.crag_escalation` is on and `shouldEscalateRetrieval` (`src/core/search/crag.ts`) says the first pass graded `weak`, was not already escalated, AND did not already run with the caller's expansion on (`callerExpanded`), the op re-runs once at `limit: max(effectiveLimit, 50)` with expansion + relational on and autocut off, keeping the better-graded run. `buildRetrievalResponseMeta(ctx, scope, …)` is the ONE producer of the `retrieval` response-meta channel (keyword-only path included): when a remote caller's scope holds pages of any kind below the safe-chunk index version (`hasUnsealedPagesInScope`: sargable `chunker_version < SAFE_FENCE_CHUNKER_VERSION` LIMIT 1 probe served by the unsealed-only partial `pages_safe_chunk_pending_idx` — NOT the COALESCE `safeChunksFilter` form; pinned by `test/search-safe-index-probe.test.ts`; fail-open; retains source, private, quarantine and live-page policy), it appends the `safe_index_pending` degraded stage to empty and partial results alike, so neither reads as a clean or complete answer; the drain is `gbrain repair safe-chunks`. The withholding itself is unchanged. Empty and nonempty replies also carry projection_readiness, with projection_pending/projection_status_unknown degradation when appropriate (projection_by_design when the only unsealed pages in scope are protected-OCR images, #6803). Vector candidate incompleteness and scoped pool details survive the public CLI/MCP serialization boundary; public type filters constrain the current-projection probe. Retrieval output copies and sanitizes result/metadata after grading and capture using the canonical scanner, before snippet truncation; internal pipeline/capture remains unredacted. `searchOutput` then projects the returned rows to the caller's row shape (`src/core/search/lean-rows.ts`: lean for remote callers unless `fields: "full"`, the transport chose full rows, or the caller is trusted-local; a lean row keeps `id` only when `ctx.isCallable('fetch')`, the MCP dispatch predicate `buildOperationContext` threads in, says the caller can call `fetch` (unset keeps it), and prints `score` at 4 significant digits) and reports it as `retrieval.rows` for remote callers and whenever `fields` is passed. The CLI formatter repeats this on JSON, explain and human output. System One: the `query` op asks S4 answerability (`decide.answerability`, diagnostic only) and surfaces `meta.answerability`; the crag escalation re-run keeps S2-S5 off (`rerankOnly`). Each handler times its request (`SearchTimings`, search/stage-timings.ts) and `searchOutput` emits `retrieval.timings` last. The typed-search type check lives in `ops/search-type-filter.ts` (`reconcileTypeFilter`): one statement of per-type `EXISTS` probes over each type's schema-expanded set, with the `DISTINCT` type list for the `type_filter_notice` evaluated only when a probe misses, run `jitOff` and unprepared (a generic plan scans every page per missing type); pinned by `test/search-type-filter-reconcile.test.ts` and `test/e2e/typed-search-jit-postgres.test.ts`. `buildRetrievalResponseMeta` also stamps `stale` on hits whose page's newer file is held, adds `held_files` per source in scope and emits the `held_files` degraded notice (`persistence/held-reads.ts`; Test: `test/held-read-signals.test.ts`); `coverage` counts pending, held and embedding-held items with `could_affect` (`search/retrieval-coverage.ts`). Its safe-index probe, projection readiness, entity saved facts, saved-fact match and held-file coverage run concurrently, each with its own catch; the answer-feedback write runs after them (`test/search-response-meta-concurrency.test.ts`). The saved-fact match is one statement: an uncorrelated `EXISTS` probe (a one-time filter) skips its `LIKE ANY` scan when no fact qualifies. The handlers start the alias fan-out's `resolveQueryEntity` alongside the hybrid search, and `evidenceOutput` reads page trust (`loadPageTrust` over the rows every delivered row is copied from) alongside evidence delivery (`test/search-post-rerank-concurrency.test.ts`).
-- `src/core/ops/search-source-scope.ts` — the per-request source scope of `search` and `query`: `source_id` through `federatedSearchScope`, narrowed by `source_ids` (`parseSourceIdsParam`: trimmed, deduped, validated; `__all__` refused). Each listed id is authorized like an explicit `source_id` (out-of-grant: permission_denied; non-live: unknown_source); with both params the scope is their intersection, and an empty one (`sourceIds: []`) emits `empty_retrieval` so the handlers search nothing. Tests: `test/search/search-source-ids.test.ts` (PGLite; Postgres via `test/e2e/search-source-ids-postgres.test.ts`), `test/e2e/serve-http-member-tokens.test.ts`.
+- `src/core/ops/search.ts` — the search-domain op module (`search`, `query`, `search_stats`, `search_modes`, `search_tune`, `cache_stats`). Both resolve their source scope through `ops/search-source-scope.ts` and return no rows when that scope is empty. `query` is the hybrid entry (`hybridSearchCached`) plus two non-hybrid legs that share ONE effective-row-contract helper, `resolveEffectiveLimit(ctx, p)`: an explicit `limit` wins, otherwise the mode-derived `searchLimit` resolved through the same trust-gated chain `hybridSearch` uses (`resolvePerCallMode` ignores a remote caller's `mode`, so a remote client cannot select the tokenmax row count); the config reads run lazily on those paths only. The legs: the image-similarity branch (`embedding_image` vector search, `test/query-image-mode-limit.serial.test.ts`) and the CRAG escalation slice — when `search.crag_escalation` is on and `shouldEscalateRetrieval` (`src/core/search/crag.ts`) says the first pass graded `weak`, was not already escalated, AND did not already run with the caller's expansion on (`callerExpanded`), the op re-runs once at `limit: max(effectiveLimit, 50)` with expansion + relational on and autocut off, keeping the better-graded run. `buildRetrievalResponseMeta(ctx, scope, …)` is the ONE producer of the `retrieval` response-meta channel (keyword-only path included): when a remote caller's scope holds pages of any kind below the safe-chunk index version (`hasUnsealedPagesInScope`: sargable `chunker_version < SAFE_FENCE_CHUNKER_VERSION` LIMIT 1 probe served by the unsealed-only partial `pages_safe_chunk_pending_idx` — NOT the COALESCE `safeChunksFilter` form; pinned by `test/search-safe-index-probe.test.ts`; fail-open; retains source, private, quarantine and live-page policy), it appends the `safe_index_pending` degraded stage to empty and partial results alike, so neither reads as a clean or complete answer; the drain is `gbrain repair safe-chunks`. The withholding itself is unchanged. Empty and nonempty replies also carry projection_readiness, with projection_pending/projection_status_unknown degradation when appropriate (projection_by_design when the only unsealed pages in scope are protected-OCR images, #6803). Vector candidate incompleteness and scoped pool details survive the public CLI/MCP serialization boundary; public type filters constrain the current-projection probe. Retrieval output copies and sanitizes result/metadata after grading and capture using the canonical scanner, before snippet truncation; internal pipeline/capture remains unredacted. `searchOutput` then projects the returned rows to the caller's row shape (`src/core/search/lean-rows.ts`: lean for remote callers unless `fields: "full"`, the transport chose full rows, or the caller is trusted-local; a lean row keeps `id` only when `ctx.isCallable('fetch')`, the MCP dispatch predicate `buildOperationContext` threads in, says the caller can call `fetch` (unset keeps it), and prints `score` at 4 significant digits) and reports it as `retrieval.rows` for remote callers and whenever `fields` is passed. The CLI formatter repeats this on JSON, explain and human output. System One: the `query` op asks S4 answerability (`decide.answerability`, diagnostic only) and surfaces `meta.answerability`; the crag escalation re-run keeps S2-S5 off (`rerankOnly`). Each handler times its request (`SearchTimings`, search/stage-timings.ts) and `searchOutput` emits `retrieval.timings` last. The typed-search type check lives in `ops/search-type-filter.ts` (`reconcileTypeFilter`): one statement of per-type `EXISTS` probes over each type's schema-expanded set, with the `DISTINCT` type list for the `type_filter_notice` evaluated only when a probe misses, run `jitOff` and unprepared (a generic plan scans every page per missing type); pinned by `test/search-type-filter-reconcile.test.ts` and `test/e2e/typed-search-jit-postgres.test.ts`. `buildRetrievalResponseMeta` also stamps `stale` on hits whose page's newer file is held, adds `held_files` per source in scope and emits the `held_files` degraded notice (`persistence/held-reads.ts`; Test: `test/held-read-signals.test.ts`); `coverage` counts pending, held and embedding-held items with `could_affect` (`search/retrieval-coverage.ts`). Its safe-index probe, projection readiness, entity saved facts, saved-fact match and held-file coverage run concurrently, each with its own catch; the answer-feedback write runs after them (`test/search-response-meta-concurrency.test.ts`). The saved-fact match is one statement: an uncorrelated `EXISTS` probe (a one-time filter) skips its `LIKE ANY` scan when no fact qualifies. The handlers start the alias fan-out's `resolveQueryEntity` alongside the hybrid search, and `evidenceOutput` reads page trust (`loadPageTrust` over the rows every delivered row is copied from) alongside evidence delivery (`test/search-post-rerank-concurrency.test.ts`).
+- `src/core/ops/search-source-scope.ts` — the per-request source scope of `search` and `query`: `source_id` through `federatedSearchScope`, narrowed by `source_ids` (`parseSourceIdsParam`: trimmed, deduped, validated; `__all__` refused; `[]` or a blank string is absent, #5390). Each listed id is authorized like an explicit `source_id` (out-of-grant: permission_denied; non-live: unknown_source); with both params the scope is their intersection, and an empty one (`sourceIds: []`) emits `empty_retrieval` so the handlers search nothing. Tests: `test/search/search-source-ids.test.ts` (PGLite; Postgres via `test/e2e/search-source-ids-postgres.test.ts`), `test/e2e/serve-http-member-tokens.test.ts`.
- `src/core/ops/sources.ts` — `sources_remove` is confined to the caller's WRITE authority via `assertSourceInCallerWriteScope(ctx, id)` (context.ts): an untrusted caller may hard-remove only its own write source; a federated read grant naming a source does not make it removable; any other id answers `OperationError('not_found', 'Unknown source: <id>')`, byte-identical to a nonexistent source so the error is not an existence oracle. `sources_status` keeps the read-scope helper (`assertSourceInCallerScope`), so a federated grant can still diagnose a source it cannot remove. Trusted local CLI keeps the full operator view. Over HTTP every client carries a write source (registration default `default`) and its own `oauth_clients.source_id` row FK-RESTRICTs removing that source, so hard removal is effectively an operator action (`gbrain sources remove`); a source a remote `sources_admin` caller just created via `sources_add` stays outside its authority until the operator rescopes the client. There is no `sources_archive` op — archive lives in the CLI (`gbrain sources archive`). Pinned by `test/sources-mcp.test.ts` (federated-read-only id → not_found while status still answers; write-source id → removed; unbound → any; local → any; `remote: undefined` fail-closed) and `test/e2e/sources-remote-mcp.test.ts` (real server: not_found before AND after a read-grant widen; operator CLI completes; rescoping `--source` moves the authority).
diff --git a/docs/guides/multi-source-brains.md b/docs/guides/multi-source-brains.md
index 4da53e7980..eaa833a103 100644
--- a/docs/guides/multi-source-brains.md
+++ b/docs/guides/multi-source-brains.md
@@ -146,10 +146,12 @@ grant.
naming a source outside its grant gets `permission_denied` for the whole
request, and a removed or archived source gets `unknown_source`. So the
list can narrow a request but never widen it.
+- Omitting `source_ids`, or passing `[]` or a blank string, reads every
+ source the caller can read, as before.
- With `source_id` as well, the request reads the sources in both
- (`source_id: "__all__"` keeps the list). If none are left, or the list is
- empty, nothing is searched: the result is empty with an
- `empty_retrieval` notice, never a fallback to the wider scope.
+ (`source_id: "__all__"` keeps the list). If none are left, nothing is
+ searched: the result is empty with an `empty_retrieval` notice, never a
+ fallback to the wider scope.
- `__all__` and malformed ids in the list are `invalid_params`.
Every part of the request reads the narrowed sources: keyword, vector and
diff --git a/src/core/operation-manifest.generated.ts b/src/core/operation-manifest.generated.ts
index 9326030f7d..aeb17df599 100644
--- a/src/core/operation-manifest.generated.ts
+++ b/src/core/operation-manifest.generated.ts
@@ -1309,7 +1309,7 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
"items": {
"type": "string"
},
- "description": "Narrow to these sources ([] = none)."
+ "description": "Narrow to these sources (omit or [] for all you can read)."
},
"types": {
"type": "array",
@@ -1531,7 +1531,7 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
"items": {
"type": "string"
},
- "description": "Narrow to these sources ([] = none)."
+ "description": "Narrow to these sources (omit or [] for all you can read)."
},
"cross_modal": {
"type": "string",
diff --git a/src/core/ops/search-source-scope.ts b/src/core/ops/search-source-scope.ts
index e8065a44ba..f75045e111 100644
--- a/src/core/ops/search-source-scope.ts
+++ b/src/core/ops/search-source-scope.ts
@@ -8,10 +8,11 @@
* set) gets permission_denied for the whole request, and a removed or
* archived source gets unknown_source. So the list can only narrow a request
* to sources the caller could already read; the token's grant stays the
- * security boundary. With `source_id` too, the request reads their
- * intersection (`__all__` keeps the list). An empty result searches
- * nothing: the handlers return no rows rather than fall back to the ambient
- * or full scope, and an `empty_retrieval` notice says why.
+ * security boundary. An empty list or blank string is absent (#5390). With
+ * `source_id` too, the request reads their intersection (`__all__` keeps the
+ * list); an empty intersection searches nothing: the handlers return no rows
+ * rather than fall back to the ambient or full scope, and an
+ * `empty_retrieval` notice says why.
*/
import { ALL_SOURCES, isValidSourceId } from '../source-id.ts';
import type { OperationContext } from './contract.ts';
@@ -21,12 +22,15 @@ import { invalidParam } from './op-fix.ts';
export const SOURCE_IDS_PARAM = {
type: 'array' as const,
items: { type: 'string' as const },
- description: 'Narrow to these sources ([] = none).',
+ description: 'Narrow to these sources (omit or [] for all you can read).',
};
/** `source_ids` as distinct, trimmed source ids; undefined when absent. */
export function parseSourceIdsParam(ctx: OperationContext, tool: 'search' | 'query', raw: unknown): string[] | undefined {
if (raw === undefined || raw === null) return undefined;
+ // #5390: OpenAI-family MCP clients fill every optional param with an empty value; [] and a blank string mean absent.
+ if (Array.isArray(raw) && raw.length === 0) return undefined;
+ if (typeof raw === 'string' && raw.trim() === '') return undefined;
const example = ctx.remote === false ? 'source-a,source-b' : ['source-a', 'source-b'];
if (!Array.isArray(raw)) throw invalidParam(ctx, tool, 'source_ids', '`source_ids` must be an array of source ids.', { example });
const ids = new Set<string>();
@@ -54,8 +58,7 @@ export async function requestSourceScope(ctx: OperationContext, sourceIdParam: s
for (const id of [sourceIdParam, ...sourceIds]) await assertExplicitSourceLive(ctx, id);
const narrowed = sourceIdParam === undefined || sourceIdParam === ALL_SOURCES ? sourceIds : sourceIds.filter(id => id === sourceIdParam);
if (narrowed.length === 0) {
- ctx.emitNotice?.({ code: 'empty_retrieval', kind: 'info',
- why: sourceIds.length === 0 ? 'source_ids was empty, so no source was searched.' : `source_ids does not include source_id '${sourceIdParam}', so no source was searched.` });
+ ctx.emitNotice?.({ code: 'empty_retrieval', kind: 'info', why: `source_ids does not include source_id '${sourceIdParam}', so no source was searched.` });
}
return { sourceIds: narrowed };
}
diff --git a/test/fixtures/goldens/cli/help-and-errors.json b/test/fixtures/goldens/cli/help-and-errors.json
index 105aee779d..f5c0d2a47f 100644
--- a/test/fixtures/goldens/cli/help-and-errors.json
+++ b/test/fixtures/goldens/cli/help-and-errors.json
@@ -745,7 +745,7 @@
" --since On/after: YYYY-MM-DD or 7d/2w/1y.",
" --until On/before.",
" --source-id One source, or '__all__'.",
- " --source-ids Narrow to these sources ([] = none).",
+ " --source-ids Narrow to these sources (omit or [] for all you can read).",
" --cross-modal Default auto.",
" --embedding-column Registered embedding column.",
" --adaptive-return true for one answer (fewer rows, never empty); omit for breadth.",
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index afc2031295..f869881c81 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": 263140,
- "stdoutSha256": "1c472b785ce9480da19240c8b8fd36d52593149294542069d6ba20813ef4c192",
+ "stdoutBytes": 263184,
+ "stdoutSha256": "c7005801cc52a1238f2d591e5f00e0d58b16c4a379a02659bbeabec655ee402d",
"toolNames": [
"remember",
"entity",
@@ -1723,7 +1723,7 @@
"type": "string"
},
"source_ids": {
- "description": "Narrow to these sources ([] = none).",
+ "description": "Narrow to these sources (omit or [] for all you can read).",
"items": {
"type": "string"
},
@@ -1936,7 +1936,7 @@
"type": "string"
},
"source_ids": {
- "description": "Narrow to these sources ([] = none).",
+ "description": "Narrow to these sources (omit or [] for all you can read).",
"items": {
"type": "string"
},
diff --git a/test/search/search-source-ids.test.ts b/test/search/search-source-ids.test.ts
index 01adc76248..caf3bb2215 100644
--- a/test/search/search-source-ids.test.ts
+++ b/test/search/search-source-ids.test.ts
@@ -6,13 +6,15 @@
* member may see. The request reads the intersection of `source_ids` and
* the caller's readable sources; each id is authorized exactly as an
* explicit `source_id` is (out-of-grant ids refuse with permission_denied
- * for remote callers, non-live ids refuse with unknown_source), and an
- * empty narrowed scope searches nothing.
+ * for remote callers, non-live ids refuse with unknown_source). An empty
+ * list or blank string is absent (#5390); a non-empty list whose
+ * intersection with `source_id` is empty searches nothing.
* 2. Fails when: the param is dropped or unknown (local callers read every
* source), any arm (keyword, vector, title, alias fan-out, entity
* anchoring, facts arm, saved facts, CRAG re-run, think escalation,
- * evidence delivery, keyword paging) reads past the narrowed scope, or an
- * empty narrowed scope falls back to the ambient or full scope.
+ * evidence delivery, keyword paging) reads past the narrowed scope, an
+ * empty intersection falls back to the ambient or full scope, or an empty
+ * list stops behaving like an omitted one.
* 3. Existing coverage pins only the scalar `source_id` (search-op-source-id).
* 4. No production seam: the gateway embed transport stub and an engine proxy
* that records each search call's scope.
@@ -187,11 +189,14 @@ for (const kind of testBackends()) {
expectNoSourceB(out);
});
- test(`${op}: an empty array searches nothing and says so`, async () => {
- const out = await run(op, { query: 'zephyrblatt orchard harvest', source_ids: [] });
- expect(out.rows).toEqual([]);
- expect(out.calls).toEqual([]);
- expect(out.notices.map(n => n.code)).toContain('empty_retrieval');
+ test(`${op}: an empty array or blank string behaves exactly like omitting it`, async () => {
+ const omitted = slugs(await run(op, { query: 'zephyrblatt orchard harvest' })).sort();
+ expect(omitted).toEqual(expect.arrayContaining(['notes/orchard-alpha', 'notes/orchard-bravo', 'notes/orchard-charlie']));
+ for (const sourceIds of [[], '', ' ']) {
+ const out = await run(op, { query: 'zephyrblatt orchard harvest', source_ids: sourceIds });
+ expect(slugs(out).sort()).toEqual(omitted);
+ expect(out.notices.map(n => n.code)).not.toContain('empty_retrieval');
+ }
});
test(`${op}: source_id intersects source_ids (disjoint pair searches nothing)`, async () => {
@@ -202,6 +207,7 @@ for (const kind of testBackends()) {
const disjoint = await run(op, { query: 'zephyrblatt orchard harvest', source_id: 'source-b', source_ids: ['source-a'] });
expect(disjoint.rows).toEqual([]);
expect(disjoint.calls).toEqual([]);
+ expect(disjoint.notices.map(n => n.code)).toContain('empty_retrieval');
const all = await run(op, { query: 'zephyrblatt orchard harvest', source_id: '__all__', source_ids: ['source-a'] });
expectNoSourceB(all);
});
@@ -213,6 +219,8 @@ for (const kind of testBackends()) {
expect(await refusal(run(op, { query: 'zephyrblatt', source_ids: ['__all__'] }))).toBe('invalid_params');
expect(await refusal(run(op, { query: 'zephyrblatt', source_ids: 'source-a' }))).toBe('invalid_params');
expect(await refusal(run(op, { query: 'zephyrblatt', source_ids: [7] }))).toBe('invalid_params');
+ expect(await refusal(run(op, { query: 'zephyrblatt', source_ids: [''] }))).toBe('invalid_params');
+ expect(await refusal(run(op, { query: 'zephyrblatt', source_ids: ',' }))).toBe('invalid_params');
});
}
@@ -311,10 +319,15 @@ for (const kind of testBackends()) {
});
}
- test(`${op}: an empty array searches nothing`, async () => {
- const out = await run(op, { query: 'zephyrblatt orchard harvest', source_ids: [] }, remote);
- expect(out.rows).toEqual([]);
- expect(out.calls).toEqual([]);
+ test(`${op}: an empty array or blank string reads the grant, exactly like omitting it`, async () => {
+ const omitted = await run(op, { query: 'zephyrblatt orchard harvest', fields: 'full' }, remote);
+ expect(slugs(omitted)).toContain('notes/orchard-alpha');
+ expectNoSourceB(omitted);
+ for (const sourceIds of [[], '']) {
+ const out = await run(op, { query: 'zephyrblatt orchard harvest', fields: 'full', source_ids: sourceIds }, remote);
+ expect(slugs(out).sort()).toEqual(slugs(omitted).sort());
+ expectNoSourceB(out);
+ }
});
test(`${op}: the alias fan-out cannot reach source-b`, async () => {