Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

projections drain builds unsealed segmented pages; searchable_fix and doctor name it

garrytan9b31ef50741c
diff --git a/docs/guides/memory-boundaries.md b/docs/guides/memory-boundaries.md
index 6d7fc92a75..6478a0879e 100644
--- a/docs/guides/memory-boundaries.md
+++ b/docs/guides/memory-boundaries.md
@@ -172,7 +172,11 @@ about 10 seconds for 20 MB: its receipt says `searchable: "pending"`, with
`searchable_retry_after_ms` and a `searchable_fix` that reads the receipt again
(`get_write_request`, `gbrain write-request -- <id>`). Read it at that interval
until it says `searchable: true`; search finds the page from then on. Until
-then, search does not return the page. A quarantined page says
+then, search does not return the page. If it still says `"pending"` after a
+minute, no running gbrain process is building it (a brain with no resident
+writer, or a build that died): `gbrain projections drain`, the fix's fallback,
+builds it now, and doctor `text_projection_readiness` names how many such
+pages wait. A quarantined page says
`searchable: false`. `gbrain import` waits for the build and reports
`searchable` in its result the same way.
diff --git a/docs/guides/repair.md b/docs/guides/repair.md
index b8dea7037c..415c79c933 100644
--- a/docs/guides/repair.md
+++ b/docs/guides/repair.md
@@ -291,6 +291,12 @@ its own: each pass rebuilds up to 100 pages and starts no new page after
250 ms, and takes 2 pages while writes are waiting. A page whose rebuild fails
is retried after 30 seconds.
+Pages stored in segments are drained first, one build each; a page another
+gbrain process is building (its claim renewed within the last 60 seconds) is
+left to that process. This is how a brain with no resident (CLI only, or
+driven by cron) makes a large new page searchable after its post-commit build
+died.
+
To drain now:
```bash
diff --git a/src/commands/doctor/checks/projection-readiness.ts b/src/commands/doctor/checks/projection-readiness.ts
index c58a58ea00..650d22fd75 100644
--- a/src/commands/doctor/checks/projection-readiness.ts
+++ b/src/commands/doctor/checks/projection-readiness.ts
@@ -16,6 +16,12 @@ const CODE_REPAIR = 'For code metadata repair, run `gbrain reindex-code --force
*/
export async function checkProjectionReadiness(engine: BrainEngine, scope: PageReadScope = {}, opts: { resident?: boolean } = {}): Promise<Check> {
const readiness = await probeProjectionReadiness(engine, scope);
+ // Wave B: pages stored in segments whose chunks were not built after their write committed (not searchable yet);
+ // counted brain-wide, so only for an unscoped (local) doctor.
+ const segmented = readiness.status === 'projection_pending' && Object.keys(scope).length === 0 ? Number((await engine.executeRaw<{ n: number }>(`SELECT count(*)::int AS n FROM pages
+ WHERE deleted_at IS NULL AND body_storage='segmented' AND text_projection_revision IS DISTINCT FROM knowledge_revision`).catch(() => []))[0]?.n ?? 0) : 0;
+ const segmentedNote = segmented ? ` ${segmented} page(s) stored in segments are not searchable yet; ${opts.resident
+ ? 'the resident builds them too.' : '`gbrain projections drain` builds them as well.'}` : '';
return {
name: 'text_projection_readiness',
status: readiness.ready ? 'ok' : 'warn',
@@ -24,9 +30,9 @@ export async function checkProjectionReadiness(engine: BrainEngine, scope: PageR
: readiness.status === 'projection_pending'
? `Visible pages have missing or stale text projections; search and code results may be incomplete. ${opts.resident
? 'The resident gbrain process that holds this PGLite brain is rebuilding queued Markdown and code projections (up to 100 pages per pass, fewer while writes wait). On the brain host, `gbrain doctor` shows the pending count and how to drain faster.'
- : 'Run `gbrain projections drain` to rebuild queued Markdown and code projections now; it is safe while `gbrain serve` runs on Postgres.'} ${CODE_REPAIR} ${UNCHANGED}`
+ : 'Run `gbrain projections drain` to rebuild queued Markdown and code projections now; it is safe while `gbrain serve` runs on Postgres.'}${segmentedNote} ${CODE_REPAIR} ${UNCHANGED}`
: 'Text projection readiness is unknown because its read-only probe failed; index completeness could not be verified.',
- details: { readiness: readiness.status, ready: readiness.ready },
+ details: { readiness: readiness.status, ready: readiness.ready, ...(segmented ? { segmented_pending: segmented } : {}) },
};
}
diff --git a/src/commands/projections.ts b/src/commands/projections.ts
index cb6a523800..05d6e37fb0 100644
--- a/src/commands/projections.ts
+++ b/src/commands/projections.ts
@@ -1,7 +1,8 @@
/**
* `gbrain projections drain` (#5401): rebuilds queued Markdown and code text
* projections in-process, in batches of up to 100, until every row queued
- * before the run started has been tried once. Trusted local CLI only; it is not
+ * before the run started has been tried once; pages stored in segments go
+ * first through buildSegmentedProjection, skipping a live claim (Wave B). Trusted local CLI only; it is not
* an operation, so MCP and remediation cannot run it.
*
* Postgres: safe beside a resident owner, because each page is rebuilt under
@@ -26,7 +27,8 @@ export const PROJECTION_DRAIN_DOCS = 'docs/guides/repair.md#projection-drain';
export const PROJECTIONS_HELP = `Usage: gbrain projections drain [--limit <n>] [--json]
Rebuild queued Markdown and code text projections now, in batches of up to 100,
-until every row queued before the run started has been tried once.
+until every row queued before the run started has been tried once. Pages stored
+in segments are built first, except one another gbrain process is building.
--limit <n> Try at most n pages in this run (default: no cap)
--json Print {rebuilt, superseded, failed, remaining} to stdout
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index af384c46b1..24cae4e6a2 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -654,6 +654,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
{ since: 'TBD', text: 'Forget and purge on a page stored in segments now rewrite and re-index only the segments that hold the struck or purged row.' },
{ since: 'TBD', text: 'Export accepts a page stored in segments up to the page ceiling (was 32 MiB per page), streams it to disk, and still aborts rather than produce a partial export.' },
{ since: 'TBD', text: 'A write that stores a page in segments says in its receipt whether search sees it: `searchable: true` when it commits (every new page up to 4 MiB and every rewrite), or `searchable: "pending"` for a larger new page while its chunks are built after commit, with `searchable_retry_after_ms` and a `searchable_fix` that reads the receipt again (`get_write_request`) until it says `searchable: true`. A new page up to 4 MiB was previously searchable only once a post-commit build finished.' },
+ { since: 'TBD', text: '`gbrain projections drain` now builds pages stored in segments whose post-commit build never ran or died, skipping one another process is still building (claim renewed within 60 s), so a brain with no resident writer can make a large new page searchable. A pending receipt\'s `searchable_fix` names it as the fallback after the re-read wait, and doctor `text_projection_readiness` counts such pages (`segmented_pending`) and points to it.' },
{ since: 'TBD', text: 'Chunks of a page stored in segments keep a Markdown heading with the text after it, so a section appended after a full last chunk re-embeds only its own chunk (was two). Inline pages chunk as before.' },
];
diff --git a/src/core/page-body/projection.ts b/src/core/page-body/projection.ts
index 769b0172e3..187f36042f 100644
--- a/src/core/page-body/projection.ts
+++ b/src/core/page-body/projection.ts
@@ -26,7 +26,8 @@ import type { BrainEngine } from '../engine.ts';
import { isQuarantined } from '../quarantine.ts';
import { faultPoint } from '../persistence/fault-points.ts';
import { sealSegmentedPage } from '../persistence/segmented-apply.ts';
-import { PROJECTION_RETRY_READY_SQL, SEGMENTED_PROJECTION_CLAIM, SEGMENTED_PROJECTION_LEASE_SECONDS } from '../page-state/projections.ts';
+import { PROJECTION_RETRY_READY_SQL, SEGMENTED_JOB_PROBES, SEGMENTED_PROJECTION_CLAIM, SEGMENTED_PROJECTION_CLAIMED_SQL, SEGMENTED_PROJECTION_LEASE_SECONDS,
+ type ProjectionRebuildFailure } from '../page-state/projections.ts';
import { occurrencesWithoutChunks, stageOccurrenceChunks } from './ingest.ts';
import { DEFAULT_FLIP_RETIRE_MAX_ROWS } from './limits.ts';
import type { JsonObject } from './types.ts';
@@ -113,32 +114,43 @@ async function buildClaimedProjection(engine: BrainEngine, ref: { sourceId: stri
/**
* The projection queue's segmented route: the queued rows of live segmented
- * pages (failed rows after their retry window), rebuilt by
+ * pages (failed rows after their retry window, unless `retryCooldown` is
+ * false; never a row another process's live claim holds), rebuilt by
* `buildSegmentedProjection` at the queued revision. A failure marks the row
* `rebuild_failed` like the inline route; a page whose revision moved is
- * left to the row the trigger queued for its new revision.
+ * left to the row the trigger queued for its new revision. `listed` names
+ * every row this call took (`<source_incarnation>/<slug>`), for a caller that
+ * tries each row once (`exclude`: `gbrain projections drain`).
*/
export async function rebuildPendingSegmentedProjections(engine: BrainEngine, limit: number,
- opts: { deadlineMs?: number; now?: () => number } = {}): Promise<{ rebuilt: number; failed: number }> {
+ opts: { deadlineMs?: number; now?: () => number; notAfter?: string; reasons?: readonly string[]; retryCooldown?: boolean; exclude?: readonly string[];
+ onFailure?: (failure: ProjectionRebuildFailure) => void } = {}): Promise<{ rebuilt: number; failed: number; listed: string[] }> {
const now = opts.now ?? Date.now;
const startedAt = now();
+ const params: unknown[] = [Math.max(1, limit)];
+ const filters = [opts.retryCooldown === false ? `NOT ${SEGMENTED_PROJECTION_CLAIMED_SQL}` : PROJECTION_RETRY_READY_SQL];
+ if (opts.notAfter !== undefined) filters.push(`j.updated_at<=$${params.push(opts.notAfter)}::text::timestamptz`);
+ if (opts.reasons) filters.push(`j.reason=ANY($${params.push(opts.reasons)}::text[])`);
+ if (opts.exclude?.length) filters.push(`NOT (j.source_incarnation::text || '/' || j.slug)=ANY($${params.push(opts.exclude)}::text[])`);
const jobs = await engine.executeRaw<{ source_id: string; source_incarnation: string; slug: string; revision: string }>(`SELECT s.id AS source_id,
j.source_incarnation::text AS source_incarnation, j.slug, j.revision::text AS revision
- FROM page_projection_jobs j JOIN sources s ON s.incarnation=j.source_incarnation AND NOT s.archived
- JOIN pages p ON p.source_id=s.id AND p.slug=j.slug AND p.deleted_at IS NULL AND p.body_storage='segmented'
- WHERE ${PROJECTION_RETRY_READY_SQL} ORDER BY j.updated_at, j.slug LIMIT $1`, [Math.max(1, limit)]);
+ FROM page_projection_jobs j ${SEGMENTED_JOB_PROBES}
+ WHERE ${filters.join(' AND ')} ORDER BY j.updated_at, j.slug LIMIT $1`, params);
let rebuilt = 0, failed = 0;
+ const listed: string[] = [];
for (const [index, job] of jobs.entries()) {
if (opts.deadlineMs !== undefined && index > 0 && now() - startedAt >= opts.deadlineMs) break;
+ listed.push(`${job.source_incarnation}/${job.slug}`);
try {
if (!(await buildSegmentedProjection(engine, { sourceId: job.source_id, slug: job.slug }, { expectedRevision: job.revision })).sealed) continue;
rebuilt++;
await engine.executeRaw('DELETE FROM page_projection_jobs WHERE source_incarnation=$1::uuid AND slug=$2 AND revision=$3::uuid', [job.source_incarnation, job.slug, job.revision]);
- } catch {
+ } catch (error) {
failed++;
await engine.executeRaw(`UPDATE page_projection_jobs SET reason='rebuild_failed', updated_at=now()
WHERE source_incarnation=$1::uuid AND slug=$2 AND revision=$3::uuid`, [job.source_incarnation, job.slug, job.revision]);
+ opts.onFailure?.({ source_id: job.source_id, slug: job.slug, reason: (error instanceof Error ? error.message : String(error)).split('\n')[0]!.slice(0, 300) });
}
}
- return { rebuilt, failed };
+ return { rebuilt, failed, listed };
}
diff --git a/src/core/page-state/projections.ts b/src/core/page-state/projections.ts
index 4a4edec5e1..818164866e 100644
--- a/src/core/page-state/projections.ts
+++ b/src/core/page-state/projections.ts
@@ -401,6 +401,9 @@ export async function preparePageProjection(prepared: ProjectionSnapshot) {
// these reads walk jobs and probe sources/pages per job. The OFFSET 0 fences
// keep the planner from turning the probes back into a scan of pages; PGLite
// has no autovacuum to give it accurate queue statistics.
+/** The queue rows the segmented route (page-body/projection.ts) rebuilds: live segmented pages of active sources. */
+export const SEGMENTED_JOB_PROBES = `JOIN sources s ON s.incarnation=j.source_incarnation AND NOT s.archived
+ JOIN pages p ON p.source_id=s.id AND p.slug=j.slug AND p.deleted_at IS NULL AND p.body_storage='segmented'`;
const PROJECTION_JOB_PROBES = `CROSS JOIN LATERAL (SELECT s.id FROM sources s
WHERE s.incarnation=j.source_incarnation AND NOT s.archived OFFSET 0) s
CROSS JOIN LATERAL (SELECT p.page_kind FROM pages p WHERE p.source_id=s.id AND p.slug=j.slug
@@ -426,8 +429,9 @@ export const SEGMENTED_PROJECTION_LEASE_SECONDS = 60;
* over `page_projection_jobs j`, shared by the consumer's idle probe and the
* resident's selector.
*/
+export const SEGMENTED_PROJECTION_CLAIMED_SQL = `(j.reason='${SEGMENTED_PROJECTION_CLAIM}' AND j.updated_at>=now()-interval '${SEGMENTED_PROJECTION_LEASE_SECONDS} seconds')`;
export const PROJECTION_RETRY_READY_SQL = "(j.reason IS DISTINCT FROM 'rebuild_failed' OR j.updated_at<now()-interval '30 seconds')"
- + ` AND NOT (j.reason='${SEGMENTED_PROJECTION_CLAIM}' AND j.updated_at>=now()-interval '${SEGMENTED_PROJECTION_LEASE_SECONDS} seconds')`;
+ + ` AND NOT ${SEGMENTED_PROJECTION_CLAIMED_SQL}`;
export interface ProjectionRebuildFailure { source_id: string; slug: string; reason: string }
@@ -465,7 +469,8 @@ export async function projectionBacklog(engine: Pick<BrainEngine, 'executeRaw'>)
const [row] = await engine.executeRaw<{ pending: number; failed: number; oldest: number | null }>(`SELECT COUNT(*)::int AS pending,
COUNT(*) FILTER (WHERE j.reason='rebuild_failed')::int AS failed,
EXTRACT(EPOCH FROM now()-MIN(j.updated_at))::float8 AS oldest
- FROM page_projection_jobs j ${PROJECTION_JOB_PROBES}`);
+ FROM (SELECT j.reason, j.updated_at FROM page_projection_jobs j ${PROJECTION_JOB_PROBES}
+ UNION ALL SELECT j.reason, j.updated_at FROM page_projection_jobs j ${SEGMENTED_JOB_PROBES}) j`);
const oldest = row?.oldest === null || row?.oldest === undefined ? null : Math.max(0, Math.floor(Number(row.oldest)));
return { pending: Number(row?.pending ?? 0), failed: Number(row?.failed ?? 0), oldest_age_seconds: oldest };
}
@@ -578,6 +583,12 @@ export async function rebuildPendingPageProjections(engine: BrainEngine, limit =
/** #6286: queued projections are rebuilt in batches of this many pages. */
const DRAIN_BATCH = 100;
+/**
+ * @internal Work the drain does, for its tests: route batches it ran (`batches`), and queued pages each route tried
+ * (`inline_pages`: rebuilt, healed or failed; `segmented_pages`: every segmented row listed, built or not).
+ */
+export const projectionDrainWork = { batches: 0, inline_pages: 0, segmented_pages: 0 };
+
export interface ProjectionDrainResult {
rebuilt: number;
superseded: number;
@@ -600,6 +611,21 @@ export async function drainProjections(engine: BrainEngine, opts: { limit?: numb
let superseded = 0;
let tried = 0;
try {
+ // Wave B: pages stored in segments first, through their own route, each queued row listed once per run. A row
+ // another process's live claim holds is not listed; one that row's build leaves unsealed stays queued.
+ const { rebuildPendingSegmentedProjections } = await import('../page-body/projection.ts');
+ const listed: string[] = [];
+ while (opts.limit === undefined || tried < opts.limit) {
+ const batch = await rebuildPendingSegmentedProjections(engine, Math.min(DRAIN_BATCH, (opts.limit ?? Infinity) - tried),
+ { notAfter: runStart, reasons: opts.reasons, retryCooldown: false, exclude: listed, onFailure: failure => { failed.push(failure); } });
+ projectionDrainWork.batches++;
+ projectionDrainWork.segmented_pages += batch.listed.length;
+ if (!batch.listed.length) break;
+ listed.push(...batch.listed);
+ rebuilt += batch.rebuilt;
+ tried += batch.listed.length;
+ opts.progress?.tick(batch.listed.length, `${rebuilt} rebuilt, ${failed.length} failed`);
+ }
// Continue while a batch rebuilt, removed, failed or durably deferred a
// row; stop on a no-op batch. A bare `superseded` row (another worker
// consumed it) is not progress, so one row can never spin the drain.
@@ -612,6 +638,8 @@ export async function drainProjections(engine: BrainEngine, opts: { limit?: numb
rebuilt += batch.rebuilt;
superseded += batch.superseded;
const progressed = batch.rebuilt + healed + failedNow;
+ projectionDrainWork.batches++;
+ projectionDrainWork.inline_pages += progressed;
if (progressed === 0) break;
tried += progressed;
opts.progress?.tick(progressed, `${rebuilt} rebuilt, ${failed.length} failed`);
diff --git a/src/core/persistence/searchable.ts b/src/core/persistence/searchable.ts
index 4e768115cf..405b6584c2 100644
--- a/src/core/persistence/searchable.ts
+++ b/src/core/persistence/searchable.ts
@@ -7,7 +7,8 @@
* create, a deferred retirement), `false` for a quarantined page. A pending
* outcome is re-read here whenever the receipt is served (the put_page reply,
* get_write_request): `true` once the page's projection is sealed, else
- * `'pending'` with the poll interval and the receipt read that tells.
+ * `'pending'` with the poll interval and the receipt read that tells, then
+ * `gbrain projections drain` as the fallback when no process builds it.
*/
import type { OperationContext } from '../ops/contract.ts';
import { cliRenderContext, renderAction, type RenderContext } from '../agent-output.ts';
@@ -46,6 +47,9 @@ export async function liveSearchable(ctx: Pick<OperationContext, 'engine' | 'rem
consent: [], actor: 'agent', requires_exclusive: false,
why: `The write committed, but search does not see ${receipt.slug} yet: its chunks and keyword index are built after commit. `
+ `Read this receipt again after ${retryAfterMs} ms; searchable turns true once search sees the page.`,
+ then: { argv: ['gbrain', 'projections', 'drain'], consent: [], actor: 'agent', requires_exclusive: false,
+ why: `Only if searchable is still "pending" after a minute: no running gbrain process is building the page (a brain with no resident writer, `
+ + 'or a build that died). This builds every queued page now, then read the receipt again.' },
}, render),
};
}
diff --git a/test/large-pages/segmented-create-searchable.test.ts b/test/large-pages/segmented-create-searchable.test.ts
index 9c91e72d1e..d6dae7fb1a 100644
--- a/test/large-pages/segmented-create-searchable.test.ts
+++ b/test/large-pages/segmented-create-searchable.test.ts
@@ -13,10 +13,15 @@
* builds it (the write's post-commit build claims the page's queue row, so
* the resident's queue route does not chunk it a second time). A create
* within the bound that dies inside its publication leaves nothing behind.
+ * A larger create whose post-commit build died is named by doctor and
+ * built by `gbrain projections drain` once the dead build's claim lapses
+ * (exactly one build; a live claim is left alone), and the receipt's
+ * `searchable_fix` names that drain as its fallback.
* 2. Fails when: a small create publishes unsealed (its reply would depend on
* the post-commit projection beating the reply deadline), the receipt has
* no `searchable` contract, a receipt claims searchable before search sees
- * the page, or two projections chunk the same body.
+ * the page, two projections chunk the same body, or the drain skips (or
+ * races a live build of) a page stored in segments.
* 3. Existing coverage: segmented-embedding-paths.test.ts covers an unsealed
* create recovered by the projection queue and `embed`.
* 4. Runs on PGLite, and on Postgres when DATABASE_URL is set.
@@ -35,6 +40,8 @@ import { installFaultHook } from '../../src/core/persistence/fault-points.ts';
import { segmentChunkWork } from '../../src/core/page-body/ingest.ts';
import { SEGMENTED_CREATE_SEAL_MAX_BYTES } from '../../src/core/page-body/limits.ts';
import { importFromContent } from '../../src/core/import-file.ts';
+import { drainProjections, projectionDrainWork, SEGMENTED_PROJECTION_CLAIM, SEGMENTED_PROJECTION_LEASE_SECONDS } from '../../src/core/page-state/projections.ts';
+import { checkProjectionReadiness } from '../../src/commands/doctor/checks/projection-readiness.ts';
import { conversationBody } from '../helpers/conversation-page.ts';
import { isolatedPersistencePostgres } from '../helpers/persistence-postgres.ts';
import { withEnv } from '../helpers/with-env.ts';
@@ -107,6 +114,48 @@ for (const kind of testBackends()) {
expect(await found(needle, slug)).toBe(true);
}, 120_000);
+ test('a larger create whose post-commit build died is built by projections drain once its claim lapses, exactly once', async () => {
+ const slug = 'chats/drained';
+ const needle = `zzdrained${kind}`;
+ installFaultHook(point => { if (point === 'segmented:projection_staged') throw new Error('post-commit build died'); });
+ const imported = await importFromContent(engine, slug, page(SEGMENTED_CREATE_SEAL_MAX_BYTES + 256 * 1024, needle), { sourceId: 'default', noEmbed: true });
+ installFaultHook(undefined);
+ expect(imported.searchable).toBe('pending');
+ // Killed before any of its chunk rows committed.
+ await engine.executeRaw("DELETE FROM content_chunks WHERE page_id=(SELECT id FROM pages WHERE source_id='default' AND slug=$1)", [slug]);
+ const claim = (ageSeconds: number) => engine.executeRaw(`UPDATE page_projection_jobs SET reason=$2, updated_at=now()-make_interval(secs => $3)
+ WHERE slug=$1 AND source_incarnation=(SELECT incarnation FROM sources WHERE id='default')`, [slug, SEGMENTED_PROJECTION_CLAIM, ageSeconds]);
+ const reset = () => { for (const k of Object.keys(projectionDrainWork) as Array<keyof typeof projectionDrainWork>) projectionDrainWork[k] = 0; segmentChunkWork.chunks = 0; };
+
+ const doctor = await checkProjectionReadiness(engine);
+ expect(doctor.message).toContain('`gbrain projections drain` builds them as well');
+ expect((doctor.details as { segmented_pending?: number }).segmented_pending).toBe(1);
+
+ // A build another process holds (its claim is live) is left to it.
+ await claim(1);
+ reset();
+ const skipped = await drainProjections(engine);
+ expect(skipped.rebuilt).toBe(0);
+ expect(projectionDrainWork.segmented_pages).toBe(0);
+ expect(segmentChunkWork.chunks).toBe(0);
+ expect(await found(needle, slug)).toBe(false);
+
+ // The process died: its claim lapses and the drain builds the page.
+ await claim(SEGMENTED_PROJECTION_LEASE_SECONDS + 1);
+ let builds = 0;
+ installFaultHook(point => { if (point === 'segmented:projection_staged') builds++; });
+ reset();
+ const drained = await drainProjections(engine);
+ expect(drained.failed).toEqual([]);
+ expect(drained.rebuilt).toBe(1);
+ expect(drained.remaining).toBe(0);
+ expect(builds).toBe(1);
+ expect(projectionDrainWork.segmented_pages).toBe(1);
+ expect(segmentChunkWork.chunks).toBe(await pageChunks(slug));
+ expect(await found(needle, slug)).toBe(true);
+ expect((await checkProjectionReadiness(engine)).status).toBe('ok');
+ }, 180_000);
+
test('a larger create says pending, and the documented wait reaches searchable; one projection chunks it', async () => {
const slug = 'chats/projected';
const needle = `zzpending${kind}`;
@@ -132,6 +181,7 @@ for (const kind of testBackends()) {
const fix = receipt.searchable_fix as { argv: string[]; next: string; mcp?: unknown };
expect(fix.argv).toEqual(['gbrain', 'write-request', '--', requestId]);
expect(fix.next).toBe('run');
+ expect((fix as { then?: { argv: string[] } }).then?.argv).toEqual(['gbrain', 'projections', 'drain']);
release();
for (let i = 0; receipt.searchable === 'pending' && i < 600; i++) {