Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(#6007): statement budget counts only the claim that claimed the write

garrytan07d227379dee
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 58300e3e8d..77b6043eba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,7 +25,7 @@ Measured with 25 pages of 60 KB each, written over MCP to a Postgres brain 30 ms
| 25 pages, one `put_page` at a time, with polling | nearly 5 minutes (about 11 s a page) | not needed |
| 25 pages, 4 `put_pages` calls sent one after another | not available | 51 s, no polling |
| One 60 KB `put_page` | 7.2 s reply saying "pending", then polls (about 11 s total) | committed in about 6 s, in the reply |
-| SQL statements on one page's publish path | 139 | 111 |
+| SQL statements on one page's publish path | 135 | 107 |
| Backlinks between the pages you just wrote | about 30 manual `add_link` calls | built automatically after the commit |
## To take advantage of v0.60.54.0
diff --git a/test/e2e/persistence-statement-budget.test.ts b/test/e2e/persistence-statement-budget.test.ts
index 1b653d48ab..3d092599bb 100644
--- a/test/e2e/persistence-statement-budget.test.ts
+++ b/test/e2e/persistence-statement-budget.test.ts
@@ -33,12 +33,14 @@ const CRITICAL: Phase[] = ['admission', 'claim', 'prepare', 'recovery_record', '
/**
* Per-phase statement budgets, about 10% above the measured counts (#6007
- * measured admission 25, claim 9, prepare 19, recovery record 6, publication
- * 45, completion 6: 110 on the critical path, and an 8-statement receipt; the
- * code before #6007 measured 29, 9, 21, 9, 61, 10: 139, and 10).
+ * measured admission 25, claim 5, prepare 19, recovery record 6, publication
+ * 46, completion 6: 107 on the critical path, and an 8-statement receipt; the
+ * code before #6007 measured 29, 5, 21, 9, 61, 10: 135, and 10). The claim
+ * counts only the transaction that claimed this write; another tick's empty
+ * claim attempt is a consumer scan.
*/
const BUDGET: Record<string, number> = {
- admission: 28, claim: 10, prepare: 21, recovery_record: 7, publication: 50, completion: 7, critical_path: 121, receipt: 9,
+ admission: 28, claim: 6, prepare: 21, recovery_record: 7, publication: 50, completion: 7, critical_path: 118, receipt: 9,
};
const SCAN = [
@@ -74,7 +76,8 @@ function classify(records: TraceRecord[]) {
else if (/SET publication_started=true|UPDATE persistence_requests SET state=\$2,outcome/.test(text)) phase = 'publication';
else if (/UPDATE persistence_requests SET recovery=\$3/.test(text)) phase = 'recovery_record';
else if (/UPDATE persistence_requests (r )?SET recovery=NULL/.test(text)) phase = 'completion';
- else if (/FROM persistence_requests r LEFT JOIN persistence_worktrees w ON w\.id=r\.worktree_id WHERE r\.state='queued'/.test(text)) phase = 'claim';
+ // A claim transaction that claimed nothing is another consumer tick's empty attempt, not this write's claim.
+ else if (/FROM persistence_requests r LEFT JOIN persistence_worktrees w ON w\.id=r\.worktree_id WHERE r\.state='queued'/.test(text)) phase = /SET state='running'/.test(text) ? 'claim' : 'consumer_scan';
else if (/persistence_effects/.test(text)) phase = 'effects';
return { ...group, phase };
});