Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: the fold's lease read is FOR KEY SHARE since #7442 (statement pins); tag the token-census source read
garrytan71a07c547d55
diff --git a/test/drain-lease-key-share-7442.test.ts b/test/drain-lease-key-share-7442.test.tsindex 73c6ed6366..9b5ef657f9 100644--- a/test/drain-lease-key-share-7442.test.ts+++ b/test/drain-lease-key-share-7442.test.ts@@ -72,6 +72,7 @@ describe('#7442: the drain-lease fence lets the renewal through and still holdsconst assignments: string[] = [];for (const file of readdirSync('src', { recursive: true }) as string[]) {if (!file.endsWith('.ts')) continue;+ // test-reads-source-ok[structural]: the guard is a census of every token assignment in src/; a mutant that moves the token write out of the keyed upsert has no runtime symptom until a fence races it.const lines = readFileSync(join('src', file), 'utf8').split('\n');lines.forEach((line, i) => {if (!/(^|[\s,(])acquisition_token\s*=(?!=)/.test(line) || /\b(WHERE|AND|OR)\b[^,]*acquisition_token\s*=/i.test(line)) return;diff --git a/test/fixtures/fold-hook-noop-6712.json b/test/fixtures/fold-hook-noop-6712.jsonindex 96aab5eedb..8056dd941e 100644--- a/test/fixtures/fold-hook-noop-6712.json+++ b/test/fixtures/fold-hook-noop-6712.json@@ -108,7 +108,7 @@"SELECT COALESCE((completed_keys->0->>'count')::int,0) AS count FROM op_checkpoints WHERE op=$1 AND fingerprint=$2","INSERT INTO op_checkpoints(op,fingerprint,completed_keys) VALUES($1,$2,$3::text::jsonb) ON CONFLICT(op,fingerprint) DO UPDATE SET completed_keys=EXCLUDED.completed_keys,updated_at=now()","SAVEPOINT gbrain_nested_1",- "SELECT 1 FROM gbrain_cycle_locks WHERE id=$1 AND acquisition_token=$2::uuid AND ttl_expires_at > now() FOR SHARE",+ "SELECT 1 FROM gbrain_cycle_locks WHERE id=$1 AND acquisition_token=$2::uuid AND ttl_expires_at > now() FOR KEY SHARE","SELECT completed_keys->0 AS value, updated_at FROM op_checkpoints WHERE op=$1 AND fingerprint=$2","(SELECT r.request_id::text AS request_id FROM persistence_requests r WHERE r.worktree_id=$1::uuid AND r.recovery IS NOT NULL LIMIT 1) UNION ALL (SELECT r.request_id::text FROM persistence_requests r WHERE r.worktree_id=$1::uuid AND r.state IN ('queued','running','recovering') AND r.request_id<>$2::uuid AND r.intent->>'kind' IN ('managed_sync_import','managed_sync_delete','managed_sync_checkpoint') LIMIT 1) LIMIT 1","SELECT GREATEST((SELECT max(sequence) FROM persistence_requests WHERE worktree_id=$1::uuid), (SELECT max(sequence) FROM persistence_requests WHERE worktree_id IS NULL AND source_id=$2 AND source_incarnation=$3::uuid))::text AS hwm",@@ -239,7 +239,7 @@"SELECT k.row_num FROM takes k JOIN jsonb_to_recordset($2::text::jsonb) AS n(row_num integer,claim text,kind text,holder text) ON n.row_num=k.row_num WHERE k.page_id=$1 AND (k.claim,k.kind,k.holder) IS DISTINCT FROM (n.claim,n.kind,n.holder) ORDER BY k.row_num LIMIT $3","DELETE FROM takes WHERE page_id=$1 AND row_num=ANY($2::integer[])","savepoint \"s0\"",- "SELECT 1 FROM gbrain_cycle_locks WHERE id=$1 AND acquisition_token=$2::uuid AND ttl_expires_at > now() FOR SHARE",+ "SELECT 1 FROM gbrain_cycle_locks WHERE id=$1 AND acquisition_token=$2::uuid AND ttl_expires_at > now() FOR KEY SHARE","SELECT completed_keys->0 AS value, updated_at FROM op_checkpoints WHERE op=$1 AND fingerprint=$2","(SELECT r.request_id::text AS request_id FROM persistence_requests r WHERE r.worktree_id=$1::uuid AND r.recovery IS NOT NULL LIMIT 1) UNION ALL (SELECT r.request_id::text FROM persistence_requests r WHERE r.worktree_id=$1::uuid AND r.state IN ('queued','running','recovering') AND r.request_id<>$2::uuid AND r.intent->>'kind' IN ('managed_sync_import','managed_sync_delete','managed_sync_checkpoint') LIMIT 1) LIMIT 1","SELECT GREATEST((SELECT max(sequence) FROM persistence_requests WHERE worktree_id=$1::uuid), (SELECT max(sequence) FROM persistence_requests WHERE worktree_id IS NULL AND source_id=$2 AND source_incarnation=$3::uuid))::text AS hwm",diff --git a/test/helpers/managed-import-budget.ts b/test/helpers/managed-import-budget.tsindex 9739fafe4f..900bd9e09a 100644--- a/test/helpers/managed-import-budget.ts+++ b/test/helpers/managed-import-budget.ts@@ -74,7 +74,7 @@ export function publicationOf(records: StatementRecord[]): StatementRecord[] {}/** The folded stamp's first statement (its lease check) and its last when it publishes (the pass row write). */-export const FOLD_LEASE_READ = 'SELECT 1 FROM gbrain_cycle_locks WHERE id=$1 AND acquisition_token=$2::uuid AND ttl_expires_at > now() FOR SHARE';+export const FOLD_LEASE_READ = 'SELECT 1 FROM gbrain_cycle_locks WHERE id=$1 AND acquisition_token=$2::uuid AND ttl_expires_at > now() FOR KEY SHARE';export const FOLD_PASS_ROW_WRITE = /^INSERT INTO op_checkpoints\(op,fingerprint,completed_keys,updated_at\) VALUES\(\$1,\$2,jsonb_build_array\(\$3::text::jsonb\),now\(\)\)/;/**