Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Count same-input judge failures per attempt, the current revision's retries included

garrytan8d724c10b1c8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d139807d1b..e1b8850a73 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,16 +12,15 @@ identifiers and attribution are available in the pre-removal Git revision
## [0.60.631.0] - 2026-11-09
-**A long conversation that keeps growing is no longer re-extracted, and re-paid for, on every new message.** Automatic event extraction reads a page's title, date, attendees and the first 12,000 characters of its body. On a conversation longer than that, each new message recorded a new revision, and each revision paid for another extraction call on exactly the same text. The model words each event a little differently every time, event pages are named after that wording, and an extraction of a page longer than 12,000 characters never retired the previous one, so every run added a fresh copy of every event. One page could collect dozens of paid calls and hundreds of duplicate events. Now a revision that changes nothing extraction reads (text, title, date, attendees, privacy) makes no call and writes nothing (it records `judge_input_unchanged`); a window the judge keeps failing on (its answer cut off, unreadable, malformed or over the per-page spend cap) is paid for at most the page's attempt limit across all revisions, then records `judge_input_failed` until the text changes, a release changes the extractor, or a backfill asks again (a run a newer revision replaced, or a missing provider or price, never counts toward that limit); and a re-extraction that re-read all the text the page's live events came from (for example after a title change, or the first time a conversation grows past 12,000 characters) replaces those events instead of adding to them. An extraction that dropped proposals over `chronicle.max_events_per_page` is asked again when that setting or the timezone changes, and one that dropped proposals dated after the page's last day is asked again, once, when that day moves. A page whose opening text was edited still keeps its earlier events, as before. Text past the first 12,000 characters is still not extracted; incremental coverage of the tail is tracked in #9013. Reported by @andreineacsu.
+**A long conversation that keeps growing is no longer re-extracted, and re-paid for, on every new message.** Automatic event extraction reads a page's title, date, attendees and the first 12,000 characters of its body. On a conversation longer than that, each new message recorded a new revision, and each revision paid for another extraction call on exactly the same text. The model words each event a little differently every time, event pages are named after that wording, and an extraction of a page longer than 12,000 characters never retired the previous one, so every run added a fresh copy of every event. One page could collect dozens of paid calls and hundreds of duplicate events. Now a revision that changes nothing extraction reads (text, title, date, attendees, privacy) makes no call and writes nothing (it records `judge_input_unchanged`); a window the judge keeps failing on (its answer cut off, unreadable, malformed or over the per-page spend cap) is paid for at most the page's attempt limit across all revisions, retries included, then records `judge_input_failed` until the text changes, a release changes the extractor, or a backfill asks again (a run a newer revision replaced, or a missing provider or price, never counts toward that limit); and a re-extraction that re-read all the text the page's live events came from (for example after a title change, or the first time a conversation grows past 12,000 characters) replaces those events instead of adding to them. An extraction that dropped proposals over `chronicle.max_events_per_page` is asked again when that setting or the timezone changes, and one that dropped proposals dated after the page's last day is asked again, once, when that day moves. A page whose opening text was edited still keeps its earlier events, as before. Text past the first 12,000 characters is still not extracted; incremental coverage of the tail is tracked in #9013. Reported by @andreineacsu.
**Doctor counts the duplicates earlier releases left.** The new `chronicle_duplicate_events` check (info) reports how many pages hold live events from earlier extraction runs beside their newest run's, and how many such events. It changes nothing; a preview-first repair that retires them is tracked in #9012.
### Itemized changes
-- `src/core/chronicle/execute.ts`: before the daily reservation, a row whose judge input digest equals that of the page's latest decided extracted generation (no ineligible revision or chronicle retirement since) finishes `skipped` / `judge_input_unchanged` with no call; an automatic row whose input already used the attempt limit on earlier revisions without publishing finishes `failed` / `judge_input_failed` (a refused input stays `judge_refused`), with no call, counting only `judge_truncated`, `judge_parse_failed`, `malformed_proposal`, `budget_exhausted` and `judge_refused` attempts (also on a row a newer revision replaced before its retry; a judged run superseded while publishing records no judged input); a truncated generation replaces the previous one only when every live chronicle event of the page is recorded by a ledger row whose judged window the new window starts with. Ended-invite projections and held results never count as judged, and each finish writes the judged input outright, so a held retry clears what a failed attempt recorded; a generation that dropped future-dated proposals records `cutoffInputHash` (the digest keyed to the screen's cutoff day).
+- `src/core/chronicle/execute.ts`: before the daily reservation, a row whose judge input digest equals that of the page's latest decided extracted generation (no ineligible revision or chronicle retirement since) finishes `skipped` / `judge_input_unchanged` with no call; an automatic row whose input already used the attempt limit without publishing finishes `failed` / `judge_input_failed` (a refused input stays `judge_refused`), with no call, summing `judge_input_failures` over every row of the page with that digest, the current revision's retries included (only a `judge_truncated`, `judge_parse_failed`, `malformed_proposal`, `budget_exhausted` or `judge_refused` attempt increments it); a truncated generation replaces the previous one only when every live chronicle event of the page is recorded by a ledger row whose judged window the new window starts with. Ended-invite projections and held results never count as judged, and each finish that judged writes the judged input outright, so a held retry clears what a failed attempt recorded (a row a newer revision replaced before its retry keeps it); a generation that dropped future-dated proposals records `cutoffInputHash` (the digest keyed to the screen's cutoff day).
- `src/core/chronicle/extract-events.ts`: `chronicleJudgedInput` (digest of the judge input with the body cut to `JUDGE_BODY_CHARS`, the extractor version, the depth page's visibility and source incarnation, the timezone and `chronicle.max_events_per_page`; the window and its sha256) and `cutoffInputHash`.
-- `src/core/cycle/chronicle.ts`: the phase's supersede sweep keeps a row's judged input only when its last attempt was one of the counted failures.
-- Migration `v297` `chronicle_judge_window`: `chronicle_page_state.judge_input_hash`, `judge_window_chars`, `judge_window_hash`; nullable, no backfill. A row recorded before it has no window, so that page's next revision is judged once more and stays additive.
+- Migration `v297` `chronicle_judge_window`: `chronicle_page_state.judge_input_hash`, `judge_window_chars`, `judge_window_hash` (nullable) and `judge_input_failures` (`NOT NULL DEFAULT 0`); no backfill, so existing rows start at no judged input and zero counted failures. A row recorded before it has no window, so that page's next revision is judged once more and stays additive.
- `src/core/chronicle/reasons.ts`, `src/core/error-registry.ts`: reason codes `judge_input_unchanged` and `judge_input_failed`.
- `src/core/chronicle/ledger-stats.ts`, `src/commands/doctor/checks/auto-chronicle.ts`: `readChronicleDuplicateEvents` and the `chronicle_duplicate_events` doctor check.
- Docs: `docs/guides/life-chronicle.md`, `docs/guides/error-codes.md`.
diff --git a/src/core/chronicle/contract.ts b/src/core/chronicle/contract.ts
index f557609d6f..c3b825ebab 100644
--- a/src/core/chronicle/contract.ts
+++ b/src/core/chronicle/contract.ts
@@ -90,6 +90,9 @@ export interface ChronicleLedgerRow {
* starts with the same text. */
judge_window_chars?: number | null;
judge_window_hash?: string | null;
+ /** #8972: paid attempts of this row that ended in a failure a re-judge of the same input would repeat (judge_truncated,
+ * judge_parse_failed, malformed_proposal, budget_exhausted, judge_refused); 0 on rows recorded before the column existed. */
+ judge_input_failures?: number | string | null;
decided_at: Date | string;
updated_at: Date | string;
}
diff --git a/src/core/chronicle/execute.ts b/src/core/chronicle/execute.ts
index df6f0250a9..38e8e159e0 100644
--- a/src/core/chronicle/execute.ts
+++ b/src/core/chronicle/execute.ts
@@ -70,7 +70,7 @@ export type ChronicleRowOutcome =
const CONFIG_BLOCKED = new Set(['judge_llm_unavailable', 'no_pricing']);
/** #8972: outcomes of a paid judge call that a re-judge of the same input would repeat; only these count toward the same-input cap. */
-export const SAME_INPUT_FAILURES = ['judge_truncated', 'judge_parse_failed', 'malformed_proposal', 'budget_exhausted', 'judge_refused'];
+const SAME_INPUT_FAILURES = ['judge_truncated', 'judge_parse_failed', 'malformed_proposal', 'budget_exhausted', 'judge_refused'];
const LEASE_MS = 15 * 60_000;
function key(row: ChronicleLedgerRow) {
@@ -116,8 +116,10 @@ async function finish(engine: BrainEngine, row: ChronicleLedgerRow, attempt: num
state: ChronicleLedgerRow['state']; reason: string | null; nextAttemptAt: Date | null;
costUsd?: number | null; unpriced?: boolean; events?: Array<{ slug: string; hash: string }>;
judged?: ReturnType<typeof chronicleJudgedInput>;
- /** A revision replaced the row before this run judged it: a same-input failure an earlier attempt recorded keeps counting. */
- keepFailedInput?: boolean;
+ /** A revision replaced the row before this run judged it: keep what an earlier attempt judged (and its counted failures). */
+ keepJudged?: boolean;
+ /** This attempt was a paid judge call that ended in a SAME_INPUT_FAILURES outcome. */
+ countFailure?: boolean;
}): Promise<void> {
if (patch.costUsd != null) {
await engine.executeRaw(
@@ -128,13 +130,15 @@ async function finish(engine: BrainEngine, row: ChronicleLedgerRow, attempt: num
await engine.executeRaw(
`UPDATE chronicle_page_state SET state=$5, reason=$6, next_attempt_at=$7::timestamptz, unpriced=COALESCE($8::boolean, unpriced),
event_slugs=COALESCE($9::text[], event_slugs), event_hashes=COALESCE($10::text[], event_hashes),
- judge_input_hash=CASE WHEN reason = ANY($15::text[]) THEN judge_input_hash ELSE $12 END, judge_window_chars=$13::int,
- judge_window_hash=$14, updated_at=now()
+ judge_input_hash=CASE WHEN $15::boolean THEN judge_input_hash ELSE $12 END,
+ judge_window_chars=CASE WHEN $15::boolean THEN judge_window_chars ELSE $13::int END,
+ judge_window_hash=CASE WHEN $15::boolean THEN judge_window_hash ELSE $14 END,
+ judge_input_failures=judge_input_failures + $16::int, updated_at=now()
WHERE source_id=$1 AND page_id=$2 AND content_hash=$3 AND extractor_version=$4 AND attempts=$11`,
[...key(row), patch.state, patch.reason, patch.nextAttemptAt ? patch.nextAttemptAt.toISOString() : null, patch.unpriced ?? null,
patch.events ? patch.events.map((e) => e.slug) : null, patch.events ? patch.events.map((e) => e.hash) : null, attempt,
patch.judged?.inputHash ?? null, patch.judged?.window.length ?? null, patch.judged?.windowHash ?? null,
- patch.keepFailedInput ? SAME_INPUT_FAILURES : []]);
+ patch.keepJudged === true, patch.countFailure ? 1 : 0]);
}
function backoff(attempts: number, now: Date, maxAttempts: number): Date | null {
@@ -161,18 +165,17 @@ async function judgedOnSameInput(engine: BrainEngine, row: ChronicleLedgerRow, i
}
/**
- * #8972: paid attempts earlier revisions of the page already spent on exactly this input without publishing it, so a
- * judge that keeps failing on an unchanged window (output cap, malformed output, per-page cap) is not paid again for
- * every new tail message; `refused` when one of them was refused. Only outcomes a re-judge would repeat count
- * (SAME_INPUT_FAILURES, kept on a row a newer revision replaced before its retry): a judged run a newer revision
- * superseded, a provider or pricing that was not configured, or a chat error never exhausts the page.
+ * #8972: paid attempts the page already spent on exactly this input without publishing it, this revision's own retries
+ * included, so a judge that keeps failing on an unchanged window (output cap, malformed output, per-page cap) is paid
+ * at most the attempt limit across revisions; `refused` when one of them was refused. Only attempts that ended in an
+ * outcome a re-judge would repeat count (SAME_INPUT_FAILURES, each recorded in judge_input_failures): a judged run a
+ * newer revision superseded, a provider or pricing that was not configured, or a chat error never exhausts the page.
*/
async function failedAttemptsOnSameInput(engine: BrainEngine, row: ChronicleLedgerRow, inputHash: string): Promise<{ attempts: number; refused: boolean }> {
const [prior] = await engine.executeRaw<{ attempts: number | string | null; refused: boolean | null }>(
- `SELECT sum(attempts) AS attempts, bool_or(state='skipped' AND reason='judge_refused') AS refused FROM chronicle_page_state
- WHERE source_id=$1 AND page_id=$2 AND extractor_version=$3 AND content_hash<>$4 AND judge_input_hash=$5 AND state<>'extracted'
- AND (reason = ANY($6::text[]) OR reason = 'superseded')`,
- [row.source_id, Number(row.page_id), CHRONICLE_EXTRACTOR_VERSION, row.content_hash, inputHash, SAME_INPUT_FAILURES]);
+ `SELECT sum(judge_input_failures) AS attempts, bool_or(state='skipped' AND reason='judge_refused') AS refused FROM chronicle_page_state
+ WHERE source_id=$1 AND page_id=$2 AND extractor_version=$3 AND judge_input_hash=$4`,
+ [row.source_id, Number(row.page_id), CHRONICLE_EXTRACTOR_VERSION, inputHash]);
return { attempts: Number(prior?.attempts ?? 0), refused: prior?.refused === true };
}
@@ -240,7 +243,7 @@ export async function executeChronicleRow(ctx: ChronicleExecContext, row: Chroni
return done('skipped', 'page_missing');
}
if (String(snapshot.page.content_hash ?? '') !== row.content_hash) {
- await finish(engine, row, row.attempts, { state: 'skipped', reason: 'superseded', nextAttemptAt: null, keepFailedInput: true });
+ await finish(engine, row, row.attempts, { state: 'skipped', reason: 'superseded', nextAttemptAt: null, keepJudged: true });
return done('skipped', 'superseded');
}
const pin = await pinDepth(engine, snapshot);
@@ -332,7 +335,8 @@ export async function executeChronicleRow(ctx: ChronicleExecContext, row: Chroni
const failure: JudgeFailure | null = overCap && !thrown ? { state: 'failed', reason: 'budget_exhausted' } : classifyJudge(result, thrown);
if (failure) {
const next = failure.state === 'skipped' || CONFIG_BLOCKED.has(failure.reason) ? null : backoff(attempts, now, maxAttempts);
- await finish(engine, row, attempts, { state: failure.state, reason: failure.reason, nextAttemptAt: next, judged: invite ? undefined : judgedInput, ...spend });
+ await finish(engine, row, attempts, { state: failure.state, reason: failure.reason, nextAttemptAt: next, judged: invite ? undefined : judgedInput,
+ countFailure: !invite && SAME_INPUT_FAILURES.includes(failure.reason), ...spend });
if (!failure.malformed) return done(failure.state, failure.reason, judged);
console.warn(`[chronicle] ${row.slug}: the judge's events failed validation (malformed_proposal: ${describeMalformedProposals(failure.malformed)}); nothing was written${next ? ' and the row retries with backoff' : ''}.`);
return done(failure.state, failure.reason, { ...judged, malformed: failure.malformed });
@@ -357,7 +361,7 @@ export async function executeChronicleRow(ctx: ChronicleExecContext, row: Chroni
return done('failed', 'publish_error', { ...judged, dropped });
}
if (generation.superseded) {
- await finish(engine, row, attempts, { state: 'skipped', reason: 'superseded', nextAttemptAt: null, events: generation.written, ...spend });
+ await finish(engine, row, attempts, { state: 'skipped', reason: 'superseded', nextAttemptAt: null, events: generation.written, judged: invite ? undefined : judgedInput, ...spend });
return done('skipped', 'superseded', { ...judged, written: generation.written.length, dropped });
}
const reason = events.length > 0 ? null : proposals.length === 0 ? 'no_events' : allDroppedReason(dropped);
diff --git a/src/core/cycle/chronicle.ts b/src/core/cycle/chronicle.ts
index 0ea76c043a..00d3167b86 100644
--- a/src/core/cycle/chronicle.ts
+++ b/src/core/cycle/chronicle.ts
@@ -34,7 +34,7 @@ import {
type ChronicleLedgerRow, type ChronicleRunDetails,
} from '../chronicle/contract.ts';
import { CHRONICLE_TYPES, RESCUE_SLUG_PREFIXES } from '../chronicle/eligibility.ts';
-import { claimChronicleRow, executeChronicleRow, SAME_INPUT_FAILURES } from '../chronicle/execute.ts';
+import { claimChronicleRow, executeChronicleRow } from '../chronicle/execute.ts';
import { retireOrphanedChronicleEvents } from '../chronicle/publish.ts';
import { failExhaustedCampaignRows } from '../chronicle/campaign.ts';
import { defaultJudge, type ChronicleDropReason, type ChronicleJudge } from '../chronicle/extract-events.ts';
@@ -149,10 +149,9 @@ export async function runPhaseChronicle(engine: BrainEngine, opts: ChroniclePhas
await pruneChronicleReservations(engine);
await failExhaustedCampaignRows(engine);
await engine.executeRaw(
- `UPDATE chronicle_page_state c SET state='skipped', reason='superseded', next_attempt_at=NULL, updated_at=now(),
- judge_input_hash=CASE WHEN c.reason = ANY($1::text[]) THEN c.judge_input_hash END
+ `UPDATE chronicle_page_state c SET state='skipped', reason='superseded', next_attempt_at=NULL, updated_at=now()
WHERE c.state IN ('pending','failed') AND NOT EXISTS (SELECT 1 FROM pages p
- WHERE p.id=c.page_id AND p.content_hash=c.content_hash AND p.deleted_at IS NULL)`, [SAME_INPUT_FAILURES]);
+ WHERE p.id=c.page_id AND p.content_hash=c.content_hash AND p.deleted_at IS NULL)`);
}
const sources = (await engine.executeRaw<{ id: string }>('SELECT id FROM sources WHERE NOT archived ORDER BY id')).map((s) => s.id);
details.sources = sources.length;
diff --git a/src/core/pglite-schema.generated.ts b/src/core/pglite-schema.generated.ts
index f291ea9d83..0ec1645a09 100644
--- a/src/core/pglite-schema.generated.ts
+++ b/src/core/pglite-schema.generated.ts
@@ -1369,6 +1369,7 @@ CREATE TABLE IF NOT EXISTS chronicle_page_state (
judge_input_hash TEXT,
judge_window_chars INTEGER CHECK (judge_window_chars >= 0),
judge_window_hash TEXT,
+ judge_input_failures INTEGER NOT NULL DEFAULT 0 CHECK (judge_input_failures >= 0),
PRIMARY KEY (source_id, page_id, content_hash, extractor_version)
);
CREATE INDEX IF NOT EXISTS chronicle_page_state_work_idx
diff --git a/src/core/schema-embedded.generated.ts b/src/core/schema-embedded.generated.ts
index eda91a1b7b..20181cca83 100644
--- a/src/core/schema-embedded.generated.ts
+++ b/src/core/schema-embedded.generated.ts
@@ -2110,6 +2110,7 @@ CREATE TABLE IF NOT EXISTS chronicle_page_state (
judge_input_hash TEXT,
judge_window_chars INTEGER CHECK (judge_window_chars >= 0),
judge_window_hash TEXT,
+ judge_input_failures INTEGER NOT NULL DEFAULT 0 CHECK (judge_input_failures >= 0),
PRIMARY KEY (source_id, page_id, content_hash, extractor_version)
);
CREATE INDEX IF NOT EXISTS chronicle_page_state_work_idx
diff --git a/src/core/schema-migrations/v297-chronicle-judge-window.ts b/src/core/schema-migrations/v297-chronicle-judge-window.ts
index 20e5f503c2..840cce0886 100644
--- a/src/core/schema-migrations/v297-chronicle-judge-window.ts
+++ b/src/core/schema-migrations/v297-chronicle-judge-window.ts
@@ -9,9 +9,12 @@ import type { Migration } from './types.ts';
// the text the live events came from replaces them instead of adding to them.
// judge_input_hash: the digest of the whole judge input (page fields and the
// body's first JUDGE_BODY_CHARS). judge_window_chars and judge_window_hash: the
-// length and sha256 of that body window. All nullable, metadata-only, no
-// backfill: a row recorded before this migration has no judged window, so the
-// next revision of its page is judged once more and stays additive. The number
+// length and sha256 of that body window. judge_input_failures: the paid
+// attempts of this row that ended in a failure a re-judge of the same input
+// would repeat, summed per judge_input_hash for the cross-revision cap. Nullable
+// or zero, metadata-only, no backfill: a row recorded before this migration has
+// no judged window and counts no failures, so the next revision of its page is
+// judged once more and stays additive. The number
// is a placeholder restamped at the merge slot.
export const v297: Migration = {
version: 297,
@@ -21,5 +24,6 @@ export const v297: Migration = {
ALTER TABLE chronicle_page_state ADD COLUMN IF NOT EXISTS judge_input_hash TEXT;
ALTER TABLE chronicle_page_state ADD COLUMN IF NOT EXISTS judge_window_chars INTEGER CHECK (judge_window_chars >= 0);
ALTER TABLE chronicle_page_state ADD COLUMN IF NOT EXISTS judge_window_hash TEXT;
+ ALTER TABLE chronicle_page_state ADD COLUMN IF NOT EXISTS judge_input_failures INTEGER NOT NULL DEFAULT 0 CHECK (judge_input_failures >= 0);
`,
};
diff --git a/src/schema.sql b/src/schema.sql
index 318330dbf4..dd15774da5 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -2106,6 +2106,7 @@ CREATE TABLE IF NOT EXISTS chronicle_page_state (
judge_input_hash TEXT,
judge_window_chars INTEGER CHECK (judge_window_chars >= 0),
judge_window_hash TEXT,
+ judge_input_failures INTEGER NOT NULL DEFAULT 0 CHECK (judge_input_failures >= 0),
PRIMARY KEY (source_id, page_id, content_hash, extractor_version)
);
CREATE INDEX IF NOT EXISTS chronicle_page_state_work_idx
diff --git a/test/chronicle-long-conversation-8972.test.ts b/test/chronicle-long-conversation-8972.test.ts
index 6d1e8f2ead..b0ee488bef 100644
--- a/test/chronicle-long-conversation-8972.test.ts
+++ b/test/chronicle-long-conversation-8972.test.ts
@@ -70,6 +70,9 @@ async function ledger(engine: BrainEngine) {
return (await engine.executeRaw<{ state: string; reason: string | null }>(
'SELECT state, reason FROM chronicle_page_state ORDER BY decided_at, updated_at')).map((r) => [r.state, r.reason]);
}
+async function dueRetries(engine: BrainEngine) {
+ await engine.executeRaw("UPDATE chronicle_page_state SET next_attempt_at=now()-interval '1 second' WHERE state='failed' AND next_attempt_at IS NOT NULL");
+}
async function reservations(engine: BrainEngine): Promise<number> {
return (await engine.executeRaw<{ n: number }>('SELECT count(*)::int AS n FROM chronicle_judge_reservations'))[0].n;
}
@@ -331,5 +334,35 @@ describe('#8972 fix round: what counts as judged, and what exhausts a page', ()
await run(engine, judge);
expect(calls).toBe(4);
}), 180_000);
-});
+test('transient chat errors before one counted failure do not exhaust the page, and it is judged once the provider recovers', () => brain(async ({ engine, ctx }) => {
+ let body = messages(1, JUDGE_BODY_CHARS + 1_000);
+ await put(ctx, conversation(body));
+ let calls = 0;
+ const flaky: ChronicleJudge = async () => { calls++; return { events: [], failure: calls < 5 ? 'chat_error' : 'truncated' }; };
+ await run(engine, flaky);
+ for (let n = 0; n < 4; n++) { await dueRetries(engine); await run(engine, flaky); }
+ expect(calls).toBe(5);
+ expect((await ledger(engine)).at(-1)).toEqual(['failed', 'judge_truncated']);
+ const judge = rewordingJudge();
+ body += '\nbob-example: the provider is back.';
+ await put(ctx, conversation(body));
+ const r = await run(engine, judge);
+ expect(judge.inputs).toHaveLength(1);
+ expect(r.details).toMatchObject({ judged: 1, events_written: 2 });
+ }), 180_000);
+ test('retries of the current revision count toward the attempt limit: unchanged text is paid at most 5 times', () => brain(async ({ engine, ctx }) => {
+ let body = messages(1, JUDGE_BODY_CHARS + 1_000);
+ await put(ctx, conversation(body));
+ let calls = 0;
+ const failing: ChronicleJudge = async () => { calls++; return { events: [], failure: 'truncated' }; };
+ await run(engine, failing);
+ for (let n = 0; n < 3; n++) { await dueRetries(engine); await run(engine, failing); }
+ expect(calls).toBe(4);
+ body += '\nbob-example: tail message 1.';
+ await put(ctx, conversation(body));
+ for (let n = 0; n < 6; n++) { await dueRetries(engine); await run(engine, failing); }
+ expect(calls).toBe(5);
+ expect((await ledger(engine)).at(-1)).toEqual(['failed', 'judge_input_failed']);
+ }), 180_000);
+});
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-default.json b/test/fixtures/goldens/catalog/pglite-engine-init-default.json
index 72f511bf24..e9aa65f5b4 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-default.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-default.json
@@ -52,6 +52,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -2046,7 +2047,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
index cf34d9411b..d7afd4a4a3 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
@@ -52,6 +52,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -2046,7 +2047,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
index 3dc4dd9031..58e000b4a5 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
@@ -52,6 +52,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -2042,7 +2043,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json b/test/fixtures/goldens/catalog/pglite-schema-blob-default.json
index f6cb4a00e4..edc7faddf4 100644
--- a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json
+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-default.json
@@ -17,6 +17,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -1400,7 +1401,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json
index 474210e0c2..e6b895e73c 100644
--- a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json
@@ -17,6 +17,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -1400,7 +1401,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json
index 5ac9cc9e43..bcc239606c 100644
--- a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json
+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json
@@ -17,6 +17,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -1399,7 +1400,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-db-initschema.json b/test/fixtures/goldens/catalog/postgres-db-initschema.json
index 973828963f..cc6f895579 100644
--- a/test/fixtures/goldens/catalog/postgres-db-initschema.json
+++ b/test/fixtures/goldens/catalog/postgres-db-initschema.json
@@ -17,6 +17,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -1416,7 +1417,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-default.json b/test/fixtures/goldens/catalog/postgres-engine-init-default.json
index 5c96fa9e27..50a321aeda 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-default.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-default.json
@@ -52,6 +52,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -2047,7 +2048,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
index 620b35a0f9..4dfcbcaca8 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
@@ -52,6 +52,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -2047,7 +2048,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
index aff00ab438..52b505b977 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
@@ -52,6 +52,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -2043,7 +2044,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
index c789ceede1..bfd0e615aa 100644
--- a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
@@ -1219,7 +1219,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "1391 column(s) verified against live schema",
+ "message": "1392 column(s) verified against live schema",
"name": "schema_columns",
"status": "ok"
},
@@ -6323,7 +6323,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "1391 column(s) verified against live schema",
+ "message": "1392 column(s) verified against live schema",
"name": "schema_columns",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
index 89564e0632..31c451c6d6 100644
--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
@@ -1215,7 +1215,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "1397 column(s) verified against live schema",
+ "message": "1398 column(s) verified against live schema",
"name": "schema_columns",
"status": "ok"
},
@@ -6320,7 +6320,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "1397 column(s) verified against live schema",
+ "message": "1398 column(s) verified against live schema",
"name": "schema_columns",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index 5c261728fa..196a0c5ffa 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -1061,7 +1061,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "1391 column(s) verified against live schema",
+ "message": "1392 column(s) verified against live schema",
"name": "schema_columns",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index 74fc6ff617..39d1b0086d 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -1108,7 +1108,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "1391 column(s) verified against live schema",
+ "message": "1392 column(s) verified against live schema",
"name": "schema_columns",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.json
index ee06a886d5..269fb522e4 100644
--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json
+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json
@@ -1104,7 +1104,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "1397 column(s) verified against live schema",
+ "message": "1398 column(s) verified against live schema",
"name": "schema_columns",
"status": "ok"
},
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index aca213a35a..537e9c0bb3 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -4832,8 +4832,8 @@
"idempotent": true,
"name": "chronicle_judge_window",
"sql": {
- "length": 296,
- "sha256": "6ab654bed8f18f1577c5a083474073b0f2ce116a7227cf0966f332fc8963c4c9"
+ "length": 441,
+ "sha256": "c9c5914995a27a7ed7724a433c42565f8aca86cd633c5a9d38930319b4f7bf05"
},
"sqlFor": "absent",
"transaction": "absent",
diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
index 187b065383..c3de56c293 100644
--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
@@ -52,6 +52,7 @@
"chat_usage_log.chat_usage_log_pkey": "p PRIMARY KEY (id)",
"chronicle_judge_reservations.chronicle_judge_reservations_pkey": "p PRIMARY KEY (id)",
"chronicle_page_state.chronicle_page_state_attempts_check": "c CHECK ((attempts >= 0))",
+ "chronicle_page_state.chronicle_page_state_judge_input_failures_check": "c CHECK ((judge_input_failures >= 0))",
"chronicle_page_state.chronicle_page_state_judge_window_chars_check": "c CHECK ((judge_window_chars >= 0))",
"chronicle_page_state.chronicle_page_state_max_attempts_check": "c CHECK ((max_attempts > 0))",
"chronicle_page_state.chronicle_page_state_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
@@ -2046,7 +2047,8 @@
"26 cost_attempts ARRAY/_int4 NOT NULL DEFAULT '{}'::integer[]",
"27 judge_input_hash text/text NULL",
"28 judge_window_chars integer/int4 NULL",
- "29 judge_window_hash text/text NULL"
+ "29 judge_window_hash text/text NULL",
+ "30 judge_input_failures integer/int4 NOT NULL DEFAULT 0"
],
"flags": "relkind=r rls=true force_rls=false"
},