Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/capy/l5-convergence-nightly-red' into capy/convergence-pr-b-barrier-ledger

garrytan9168afd7b69b
diff --cc src/core/persistence/journal.ts
index 0895b4a95c,6338620246..e7ca91b1af
--- a/src/core/persistence/journal.ts
+++ b/src/core/persistence/journal.ts
@@@ -773,10 -734,13 +773,13 @@@ const LEASE_HELD = `EXISTS (SELECT 1 FR
* the worktree after sequence `seen` (the newest sequence when this process last claimed a sync head there) earns the sync
* side one head, so a stream of writes cannot starve it. Uncorrelated with the candidate row, so a claim reads it once.
* The FIFO claim holds back only sync rows the write would pass (sequence below it): an earlier unfinished write is the
- * head-of-root rules' business, and one stalled in another process must not stop the sync behind it.
+ * head-of-root rules' business, and one stalled in another process must not stop the sync behind it. A write queued
+ * behind an earlier queued write that waits on a sync row naming its page cannot go first either (a write never passes
+ * an earlier one), so it holds back nothing: counting it held back the very sync row the earlier write waited on, and
+ * the three rows waited on each other with no foreground commit left to earn the sync side a head.
*/
const FOREGROUND_WAITING_ON = (nonce: string, seen: string, worktree = 'TRUE') => `SELECT f.worktree_id, f.sequence FROM persistence_requests f
- WHERE ${worktree} AND f.state IN ('queued','running','recovering') AND (f.state<>'running' OR (NOT f.publication_started
+ WHERE ${worktree} AND (f.state IN ('queued','running','recovering') OR ${RELEASED_DEFERRED('f')}) AND (f.state<>'running' OR (NOT f.publication_started
AND f.claim_phase->'owner'->>'nonce' IS DISTINCT FROM ${nonce}))
AND f.recovery IS NULL AND NOT ${SYNC_KIND('f')}
AND NOT EXISTS (SELECT 1 FROM persistence_requests named WHERE named.worktree_id=f.worktree_id AND named.sequence<f.sequence