Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

revert(merge): leave held-embedding readBudgetLimited as #6803 wrote it, pending a decision

garrytanb76bfe93ac8d
diff --git a/src/core/held-embedding.ts b/src/core/held-embedding.ts
index d1217d428e..5f32d62af1 100644
--- a/src/core/held-embedding.ts
+++ b/src/core/held-embedding.ts
@@ -35,7 +35,6 @@ import { quoteIdentifier } from './search/embedding-column.ts';
import { embeddingWriteTarget } from './page-state/projections.ts';
import { reservationCostUsd } from './budget/reservation-cost.ts';
import { estimatePageEmbedUsd, listBudgetLimitedPages } from './page-embedding-budget.ts';
-import { largePageBodyFilter } from './page-size-policy.ts';
import {
approvalAmount, approvalBasis, budgetLimitedPhrase, heldApproveAction, heldPreviewCommand, renderedCommand,
type ApprovalBasis, type BudgetLimitedCounts,
@@ -57,7 +56,7 @@ export async function readBudgetLimited(engine: BrainEngine, opts: { sourceId?:
FROM page_embedding_budget b JOIN pages p ON p.id = b.page_id
CROSS JOIN LATERAL (SELECT count(*)::int AS chunks, COALESCE(sum(length(cc.chunk_text)), 0)::bigint AS chars
FROM content_chunks cc WHERE cc.page_id = p.id AND ${chunkGenerationFilter('p', 'cc')} AND ${pending}) w
- WHERE b.state <> 'open' AND ${largePageBodyFilter('p')} AND p.deleted_at IS NULL AND NOT (COALESCE(p.frontmatter, '{}'::jsonb) ? 'embed_skip') AND w.chunks > 0${bySource}
+ WHERE b.state <> 'open' AND p.deleted_at IS NULL AND NOT (COALESCE(p.frontmatter, '{}'::jsonb) ? 'embed_skip') AND w.chunks > 0${bySource}
GROUP BY 1, 2, 3 ORDER BY 1, 2, 3`, params);
const out: BudgetLimited = { held: 0, capped: 0, held_reasons: {}, pending_chunks: 0, by_source: [] };
const sources = new Map<string, BudgetLimitedSource>();
diff --git a/test/large-pages/held-budget-shrink.test.ts b/test/large-pages/held-budget-shrink.test.ts
index 40a7a30f3d..3a7c0115f5 100644
--- a/test/large-pages/held-budget-shrink.test.ts
+++ b/test/large-pages/held-budget-shrink.test.ts
@@ -6,8 +6,7 @@
* page at or under 1 MiB as unmetered), so a held row left on a page that
* shrank no longer applies: the stale-chunk queue (staleChunkWhere and the
* stale lists), the held lists (`gbrain embed --held`, doctor
- * `partial_embedding` through held-embedding.ts readBudgetLimited) and the
- * write receipts' size state ignore it, and
+ * `partial_embedding`) and the write receipts' size state ignore it, and
* the stale sweep embeds the page's chunks. Covers an inline page shrinking
* inline, a segmented page shrinking within the demotion hysteresis (it
* stays segmented under 1 MiB) and one demoted to inline.
@@ -26,7 +25,6 @@ import type { BrainEngine } from '../../src/core/engine.ts';
import { importFromContent } from '../../src/core/import-file.ts';
import { embedStaleForSource } from '../../src/core/embed-stale.ts';
import { holdPageEmbedding, listBudgetLimitedPages, readPageSizeStates } from '../../src/core/page-embedding-budget.ts';
-import { readBudgetLimited } from '../../src/core/held-embedding.ts';
import { disposePersistenceConsumer } from '../../src/core/persistence/service.ts';
import { conversationBody } from '../helpers/conversation-page.ts';
import { isolatedPersistencePostgres } from '../helpers/persistence-postgres.ts';
@@ -92,15 +90,12 @@ describe('a held large page that shrinks under 1 MiB', () => {
await holdPageEmbedding(engine, large.id, 'awaiting_approval');
expect(await sweep(engine, sourceId)).toBe(0);
expect((await listBudgetLimitedPages(engine, { sourceId })).map(p => p.slug)).toEqual([slug]);
- expect((await readBudgetLimited(engine, { sourceId })).held).toBe(1);
expect(await importFromContent(engine, slug, note(c.small, 92), { sourceId, noEmbed: true })).toMatchObject({ status: 'imported' });
const small = await pageRow(engine, sourceId, slug);
expect(small).toMatchObject({ id: large.id, body_storage: c.after });
expect(small.bytes).toBeLessThanOrEqual(1024 ** 2);
expect(await engine.countStaleChunks({ sourceId })).toBeGreaterThan(0);
- // #6803's held report (doctor partial_embedding, embed --stale) ignores the row too, while the chunks still wait.
- expect((await readBudgetLimited(engine, { sourceId })).held).toBe(0);
expect(await sweep(engine, sourceId)).toBeGreaterThan(0);
const chunks = await visibleChunks(engine, small.id);
expect(chunks.length).toBeGreaterThan(0);