perf(server): stop re-reading and re-decrypting unchanged checkpoint headers on every upgrade readiness probe (#21130)

Cloud repeats the upgrade readiness probe. Every probe loaded, decrypted and parsed the checkpoint header of each active native run and of each retained task session's last run, even when nothing had changed.

The statement that reads a run now also reads its header's row revision (xmin, ctid, updated_at, stored size) and returns the material only for a revision the process has not inspected. A bounded memo in the checkpoint owner keeps the four identifiers the answer compares. It reuses an answer only for the same binding, row revision and secrets key, loads the key again for each answer it serves, never remembers a header that failed to decrypt, and forgets a header the latest probe did not inspect.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Fable 5.2 authored and GitHub committed 2026-11-12 10:45:44 -06:00
1 parent f2e449f8f6
commit 2174f2dfa5
6 files changed
+783 -24

No files matched your search

+15
View File
@@ -3545,6 +3545,21 @@ An upgrade readiness report contains preliminary native evidence, not permission
to remove a deployment volume. Keep the checkpoint pool bounded and measure all
pools when qualifying database cost; the current size of two is a default.
Cloud repeats the upgrade readiness probe, so the probe does not read or decrypt
a checkpoint header that has not changed. The statement that reads each run also
reads its header's row revision (`xmin`, `ctid`, `updated_at` and stored size)
and returns the encrypted material only for a revision the process has not
inspected. The memo in `native-runner-checkpoint.ts` keeps four identifiers per
header, is bounded in entries and bytes, and forgets a header that the latest
probe did not inspect. It loads the secrets key again for each answer it reuses, as a direct read
does for each header, and refuses the answer when the key is missing or changed. It
never remembers a header that failed to decrypt. Measure a probe with
`pnpm --filter @paperclipai/server exec tsx scripts/benchmark-upgrade-readiness.ts --baseline-ref=<pre-fix-commit>`.
The harness runs both revisions over the same PostgreSQL rows, reports bytes
from the database, decryptions, CPU and sampled allocation per probe, and fails
unless both give the same answer after a header changes, stops decrypting or is
deleted.
Committed native Agent Chat turns recover their unanswered final reply through
the existing response presentation worker. Recovery verifies the accepted result
and final turn, agent, responsible user, native session and conversation generation.